diff options
| author | Fred Drake <fdrake@acm.org> | 1999-12-22 16:13:54 +0000 |
|---|---|---|
| committer | Fred Drake <fdrake@acm.org> | 1999-12-22 16:13:54 +0000 |
| commit | fe4b4a076919af5dc59cc379ec1202646989da3c (patch) | |
| tree | 5af24b81be72a3a0fc0c23180649a0e4e18aa152 /Modules/zlibmodule.c | |
| parent | 4720b156d9ea2dd504ebbabe962ef776ba84d58b (diff) | |
| download | cpython-fe4b4a076919af5dc59cc379ec1202646989da3c.tar.gz | |
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 7dda00f152..82863399e5 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); + } } |
