mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Add error checking to PyInit_pyexpact
The module initializer of the pyexpat module failed to check the return value of PySys_GetObject() for NULL. CID 982779
This commit is contained in:
parent
6782b14bcb
commit
7a5457b687
1 changed files with 11 additions and 1 deletions
|
@ -1701,7 +1701,15 @@ MODULE_INITFUNC(void)
|
|||
PyModule_AddStringConstant(m, "native_encoding", "UTF-8");
|
||||
|
||||
sys_modules = PySys_GetObject("modules");
|
||||
if (sys_modules == NULL) {
|
||||
Py_DECREF(m);
|
||||
return NULL;
|
||||
}
|
||||
d = PyModule_GetDict(m);
|
||||
if (d == NULL) {
|
||||
Py_DECREF(m);
|
||||
return NULL;
|
||||
}
|
||||
errors_module = PyDict_GetItem(d, errmod_name);
|
||||
if (errors_module == NULL) {
|
||||
errors_module = PyModule_New(MODULE_NAME ".errors");
|
||||
|
@ -1722,9 +1730,11 @@ MODULE_INITFUNC(void)
|
|||
}
|
||||
}
|
||||
Py_DECREF(modelmod_name);
|
||||
if (errors_module == NULL || model_module == NULL)
|
||||
if (errors_module == NULL || model_module == NULL) {
|
||||
/* Don't core dump later! */
|
||||
Py_DECREF(m);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if XML_COMBINED_VERSION > 19505
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue