[Python-checkins] r79198 - in python/branches/release26-maint: Modules/_curses_panel.c Modules/threadmodule.c

victor.stinner python-checkins at python.org
Sun Mar 21 14:13:07 CET 2010


Author: victor.stinner
Date: Sun Mar 21 14:13:07 2010
New Revision: 79198
Log:
Merged revisions 78610,78635 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk
........
 r78610 | victor.stinner | 2010年03月03日 01:43:44 +0100 (mer., 03 mars 2010) | 3 lines
 
 Issue #3299: fix thread.allocate_lock() error handler, replace PyObject_Del()
 by Py_DECREF() to fix a crash in pydebug mode.
........
 r78635 | victor.stinner | 2010年03月03日 22:53:41 +0100 (mer., 03 mars 2010) | 5 lines
 
 Issue #3299: fix curses.panel.new_panel() error handler, replace PyObject_DEL()
 by Py_DECREF() to avoid a crash in pydebug mode.
 
 Use po->wo==NULL to detect than the panel is in the lop list or not.
........
Modified:
 python/branches/release26-maint/ (props changed)
 python/branches/release26-maint/Modules/_curses_panel.c
 python/branches/release26-maint/Modules/threadmodule.c
Modified: python/branches/release26-maint/Modules/_curses_panel.c
==============================================================================
--- python/branches/release26-maint/Modules/_curses_panel.c	(original)
+++ python/branches/release26-maint/Modules/_curses_panel.c	Sun Mar 21 14:13:07 2010
@@ -178,12 +178,13 @@
 po = PyObject_NEW(PyCursesPanelObject, &PyCursesPanel_Type);
 if (po == NULL) return NULL;
 po->pan = pan;
- po->wo = wo;
- Py_INCREF(wo);
 if (insert_lop(po) < 0) {
-	PyObject_DEL(po);
+	po->wo = NULL;
+	Py_DECREF(po);
 	return NULL;
 }
+ po->wo = wo;
+ Py_INCREF(wo);
 return (PyObject *)po;
 }
 
@@ -191,8 +192,10 @@
 PyCursesPanel_Dealloc(PyCursesPanelObject *po)
 {
 (void)del_panel(po->pan);
- Py_DECREF(po->wo);
- remove_lop(po);
+ if (po->wo != NULL) {
+	Py_DECREF(po->wo);
+	remove_lop(po);
+ }
 PyObject_DEL(po);
 }
 
Modified: python/branches/release26-maint/Modules/threadmodule.c
==============================================================================
--- python/branches/release26-maint/Modules/threadmodule.c	(original)
+++ python/branches/release26-maint/Modules/threadmodule.c	Sun Mar 21 14:13:07 2010
@@ -25,12 +25,13 @@
 static void
 lock_dealloc(lockobject *self)
 {
-	assert(self->lock_lock);
-	/* Unlock the lock so it's safe to free it */
-	PyThread_acquire_lock(self->lock_lock, 0);
-	PyThread_release_lock(self->lock_lock);
-	
-	PyThread_free_lock(self->lock_lock);
+	if (self->lock_lock != NULL) {
+		/* Unlock the lock so it's safe to free it */
+		PyThread_acquire_lock(self->lock_lock, 0);
+		PyThread_release_lock(self->lock_lock);
+		
+		PyThread_free_lock(self->lock_lock);
+	}
 	PyObject_Del(self);
 }
 
@@ -148,9 +149,9 @@
 		return NULL;
 	self->lock_lock = PyThread_allocate_lock();
 	if (self->lock_lock == NULL) {
-		PyObject_Del(self);
-		self = NULL;
+		Py_DECREF(self);
 		PyErr_SetString(ThreadError, "can't allocate lock");
+		return NULL;
 	}
 	return self;
 }


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /