summaryrefslogtreecommitdiffstats
path: root/Modules/zlibmodule.c
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1999-12-22 16:13:54 (GMT)
committerFred Drake <fdrake@acm.org>1999-12-22 16:13:54 (GMT)
commit8972dfd58eb7da25cf5129f82571003d3f7ab315 (patch)
treedc0182948b2f6b5af7782c15a9afdf49dbade43e /Modules/zlibmodule.c
parent96a8fb7e99aa8d612473a1dd87e4c1deb8408898 (diff)
downloadcpython-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.c9
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);
+ }
}