For ZlibError and ZLIB_VERSION, only attempt to add entry to the

module dict if the inserted object isn't NULL (basic defensive
programming!).
This commit is contained in:
Fred Drake 1999-12-22 16:13:54 +00:00
parent 96a8fb7e99
commit 8972dfd58e
1 changed files with 6 additions and 3 deletions

View File

@ -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);
}
}