summaryrefslogtreecommitdiff
path: root/Modules/threadmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-03-21 13:13:07 +0000
committerVictor Stinner <victor.stinner@haypocalc.com>2010-03-21 13:13:07 +0000
commit27bf15ef8d6080985d313aa61d05ac92ff61e0dd (patch)
tree4fd3cff17cfff5ac45c09ead394650fdd3f6772f /Modules/threadmodule.c
parent0217c958f2a16a56433f73284f0ff16bd211a2f3 (diff)
downloadcpython-git-27bf15ef8d6080985d313aa61d05ac92ff61e0dd.tar.gz
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. ........
Diffstat (limited to 'Modules/threadmodule.c')
-rw-r--r--Modules/threadmodule.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/Modules/threadmodule.c b/Modules/threadmodule.c
index ca47ebf7c5..1f91197e4b 100644
--- a/Modules/threadmodule.c
+++ b/Modules/threadmodule.c
@@ -25,12 +25,13 @@ typedef struct {
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 @@ newlockobject(void)
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;
}