]> granicus.if.org Git - python/commitdiff
Issue #18408: Fix zlib.compressobj() to handle PyThread_allocate_lock() failure
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 8 Jul 2013 22:29:03 +0000 (00:29 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 8 Jul 2013 22:29:03 +0000 (00:29 +0200)
(MemoryError).

Modules/zlibmodule.c

index f21184a78fd56236f0f273bdfb153c2b3adebef6..da0d3db5c66b7021151b7282adb5537f85685998 100644 (file)
@@ -132,6 +132,10 @@ newcompobject(PyTypeObject *type)
     }
 #ifdef WITH_THREAD
     self->lock = PyThread_allocate_lock();
+    if (self->lock == NULL) {
+        PyErr_SetString(PyExc_MemoryError, "Unable to allocate lock");
+        return NULL;
+    }
 #endif
     return self;
 }