[Python-checkins] r78610 - python/trunk/Modules/threadmodule.c
victor.stinner
python-checkins at python.org
Wed Mar 3 01:43:44 CET 2010
Author: victor.stinner
Date: Wed Mar 3 01:43:44 2010
New Revision: 78610
Log:
Issue #3299: fix thread.allocate_lock() error handler, replace PyObject_Del()
by Py_DECREF() to fix a crash in pydebug mode.
Modified:
python/trunk/Modules/threadmodule.c
Modified: python/trunk/Modules/threadmodule.c
==============================================================================
--- python/trunk/Modules/threadmodule.c (original)
+++ python/trunk/Modules/threadmodule.c Wed Mar 3 01:43:44 2010
@@ -27,14 +27,15 @@
static void
lock_dealloc(lockobject *self)
{
- assert(self->lock_lock);
if (self->in_weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
- /* 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);
}
@@ -165,9 +166,9 @@
self->lock_lock = PyThread_allocate_lock();
self->in_weakreflist = NULL;
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