diff options
author | Fred Drake <fdrake@acm.org> | 1999-12-22 16:13:54 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 1999-12-22 16:13:54 (GMT) |
commit | 8972dfd58eb7da25cf5129f82571003d3f7ab315 (patch) | |
tree | dc0182948b2f6b5af7782c15a9afdf49dbade43e /Modules/zlibmodule.c | |
parent | 96a8fb7e99aa8d612473a1dd87e4c1deb8408898 (diff) | |
download | cpython-8972dfd58eb7da25cf5129f82571003d3f7ab315.zip cpython-8972dfd58eb7da25cf5129f82571003d3f7ab315.tar.gz cpython-8972dfd58eb7da25cf5129f82571003d3f7ab315.tar.bz2 |
For ZlibError and ZLIB_VERSION, only attempt to add entry to the
module dict if the inserted object isn't NULL (basic defensive
programming!).
Diffstat (limited to 'Modules/zlibmodule.c')
-rw-r--r-- | Modules/zlibmodule.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index 7dda00f..8286339 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); + } } |