Commit 5744a336 authored by Miss Islington (bot)'s avatar Miss Islington (bot) Committed by GitHub

Fix several reference counting bugs in pyexpat.c. (GH-9955)

(cherry picked from commit 68def052)
Co-authored-by: default avatarZackery Spytz <zspytz@gmail.com>
parent 6e573824
......@@ -398,8 +398,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);
......@@ -547,6 +549,7 @@ my_StartElementHandler(void *userData,
flag_error(self);
Py_DECREF(n);
Py_DECREF(v);
Py_DECREF(container);
return;
}
else {
......@@ -555,12 +558,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(getcode(StartElement, "StartElement", __LINE__),
......@@ -742,7 +747,6 @@ my_ElementDeclHandler(void *userData,
}
args = Py_BuildValue("NN", nameobj, modelobj);
if (args == NULL) {
Py_DECREF(modelobj);
flag_error(self);
goto finally;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment