[Python-checkins] cpython: Add error checking to PyInit_pyexpact
christian.heimes
python-checkins at python.org
Thu Sep 8 18:21:31 EDT 2016
https://hg.python.org/cpython/rev/1241ee79fc41
changeset: 103369:1241ee79fc41
user: Christian Heimes <christian at python.org>
date: Fri Sep 09 00:13:35 2016 +0200
summary:
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
files:
Modules/pyexpat.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1701,7 +1701,15 @@
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 @@
}
}
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
{
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list