From bf2e2f9bdf3366abf6004cad2cc46782d8b31367 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 9 Jul 2013 00:29:03 +0200 Subject: [PATCH] Issue #18408: Fix zlib.compressobj() to handle PyThread_allocate_lock() failure (MemoryError). --- Modules/zlibmodule.c | 4 ++++ 1 file changed, 4 insertions(+) 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; }