From: Fred Drake Date: Wed, 22 Dec 1999 16:13:54 +0000 (+0000) Subject: For ZlibError and ZLIB_VERSION, only attempt to add entry to the X-Git-Tag: v1.6a1~587 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8972dfd58eb7da25cf5129f82571003d3f7ab315;p=thirdparty%2FPython%2Fcpython.git For ZlibError and ZLIB_VERSION, only attempt to add entry to the module dict if the inserted object isn't NULL (basic defensive programming!). --- diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index 7dda00f15202..82863399e5c9 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -870,7 +870,8 @@ PyInit_zlib() (PyObject*)NULL,PYTHON_API_VERSION); d = PyModule_GetDict(m); ZlibError = PyErr_NewException("zlib.error", NULL, NULL); - PyDict_SetItemString(d, "error", ZlibError); + if (ZlibError != NULL) + PyDict_SetItemString(d, "error", ZlibError); insint(d, "MAX_WBITS", MAX_WBITS); insint(d, "DEFLATED", DEFLATED); @@ -888,6 +889,8 @@ PyInit_zlib() insint(d, "Z_FULL_FLUSH", Z_FULL_FLUSH); ver = PyString_FromString(ZLIB_VERSION); - PyDict_SetItemString(d, "ZLIB_VERSION", ver); - Py_DECREF(ver); + if (ver != NULL) { + PyDict_SetItemString(d, "ZLIB_VERSION", ver); + Py_DECREF(ver); + } }