diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index f21184a78fd..da0d3db5c66 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; }