summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2018-10-19 06:57:38 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2018-10-19 06:57:38 (GMT)
commit68def052dcd41313eff2bd9f269e22c5a941db4d (patch)
treeb0ac2cc59608bb700deea3a2b2f38f539b7c4c11 /Modules
parentd16f012f842e5719ff9fb90e217efc0f795853f2 (diff)
downloadcpython-68def052dcd41313eff2bd9f269e22c5a941db4d.zip
cpython-68def052dcd41313eff2bd9f269e22c5a941db4d.tar.gz
cpython-68def052dcd41313eff2bd9f269e22c5a941db4d.tar.bz2
Fix several reference counting bugs in pyexpat.c. (GH-9955)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/pyexpat.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index c52079e..ab3dac6 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -243,8 +243,10 @@ string_intern(xmlparseobject *self, const char* str)
if (!value) {
if (PyDict_SetItem(self->intern, result, result) == 0)
return result;
- else
+ else {
+ Py_DECREF(result);
return NULL;
+ }
}
Py_INCREF(value);
Py_DECREF(result);
@@ -393,6 +395,7 @@ my_StartElementHandler(void *userData,
flag_error(self);
Py_DECREF(n);
Py_DECREF(v);
+ Py_DECREF(container);
return;
}
else {
@@ -401,12 +404,14 @@ my_StartElementHandler(void *userData,
}
}
args = string_intern(self, name);
- if (args != NULL)
- args = Py_BuildValue("(NN)", args, container);
if (args == NULL) {
Py_DECREF(container);
return;
}
+ args = Py_BuildValue("(NN)", args, container);
+ if (args == NULL) {
+ return;
+ }
/* Container is now a borrowed reference; ignore it. */
self->in_callback = 1;
rv = call_with_frame("StartElement", __LINE__,
@@ -565,7 +570,6 @@ my_ElementDeclHandler(void *userData,
}
args = Py_BuildValue("NN", nameobj, modelobj);
if (args == NULL) {
- Py_DECREF(modelobj);
flag_error(self);
goto finally;
}