summaryrefslogtreecommitdiffstats
path: root/Modules/pyexpat.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2016-09-08 22:13:35 (GMT)
committerChristian Heimes <christian@python.org>2016-09-08 22:13:35 (GMT)
commit7a5457b6878db61910c81017d10579edb7c91512 (patch)
tree886b3f8b10b92098b77240d13be40cfa9d78b725 /Modules/pyexpat.c
parent6782b14bcba612e4a39e41992c77306217b91e30 (diff)
downloadcpython-7a5457b6878db61910c81017d10579edb7c91512.zip
cpython-7a5457b6878db61910c81017d10579edb7c91512.tar.gz
cpython-7a5457b6878db61910c81017d10579edb7c91512.tar.bz2
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
Diffstat (limited to 'Modules/pyexpat.c')
-rw-r--r--Modules/pyexpat.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index dc97e9d..b19b7be 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -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
{