summaryrefslogtreecommitdiffstats
path: root/Modules/_threadmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-03-03 00:51:28 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-03-03 00:51:28 (GMT)
commit5774043795640f7146b26d67e146f51fd4258fcc (patch)
tree2e6ea3d766f859666088bfa1ec421c83ae598216 /Modules/_threadmodule.c
parent151205f24f83f9dd538050912614848258e0f9d8 (diff)
downloadcpython-5774043795640f7146b26d67e146f51fd4258fcc.zip
cpython-5774043795640f7146b26d67e146f51fd4258fcc.tar.gz
cpython-5774043795640f7146b26d67e146f51fd4258fcc.tar.bz2
Merged revisions 78611 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r78611 | victor.stinner | 2010-03-03 01:50:12 +0100 (mer., 03 mars 2010) | 10 lines Merged revisions 78610 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. ........ ................
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 744e94d..5181d07 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);
}
@@ -160,9 +161,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;
}