From: Victor Stinner Date: Mon, 8 Jul 2013 22:29:03 +0000 (+0200) Subject: Issue #18408: Fix zlib.compressobj() to handle PyThread_allocate_lock() failure X-Git-Tag: v3.4.0a1~278 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bf2e2f9bdf3366abf6004cad2cc46782d8b31367;p=python Issue #18408: Fix zlib.compressobj() to handle PyThread_allocate_lock() failure (MemoryError). --- diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index f21184a78f..da0d3db5c6 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -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; }