Kaydet (Commit) 68def052 authored tarafından Zackery Spytz's avatar Zackery Spytz Kaydeden (comit) Serhiy Storchaka

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

üst d16f012f
...@@ -243,8 +243,10 @@ string_intern(xmlparseobject *self, const char* str) ...@@ -243,8 +243,10 @@ string_intern(xmlparseobject *self, const char* str)
if (!value) { if (!value) {
if (PyDict_SetItem(self->intern, result, result) == 0) if (PyDict_SetItem(self->intern, result, result) == 0)
return result; return result;
else else {
Py_DECREF(result);
return NULL; return NULL;
}
} }
Py_INCREF(value); Py_INCREF(value);
Py_DECREF(result); Py_DECREF(result);
...@@ -393,6 +395,7 @@ my_StartElementHandler(void *userData, ...@@ -393,6 +395,7 @@ my_StartElementHandler(void *userData,
flag_error(self); flag_error(self);
Py_DECREF(n); Py_DECREF(n);
Py_DECREF(v); Py_DECREF(v);
Py_DECREF(container);
return; return;
} }
else { else {
...@@ -401,12 +404,14 @@ my_StartElementHandler(void *userData, ...@@ -401,12 +404,14 @@ my_StartElementHandler(void *userData,
} }
} }
args = string_intern(self, name); args = string_intern(self, name);
if (args != NULL)
args = Py_BuildValue("(NN)", args, container);
if (args == NULL) { if (args == NULL) {
Py_DECREF(container); Py_DECREF(container);
return; return;
} }
args = Py_BuildValue("(NN)", args, container);
if (args == NULL) {
return;
}
/* Container is now a borrowed reference; ignore it. */ /* Container is now a borrowed reference; ignore it. */
self->in_callback = 1; self->in_callback = 1;
rv = call_with_frame("StartElement", __LINE__, rv = call_with_frame("StartElement", __LINE__,
...@@ -565,7 +570,6 @@ my_ElementDeclHandler(void *userData, ...@@ -565,7 +570,6 @@ my_ElementDeclHandler(void *userData,
} }
args = Py_BuildValue("NN", nameobj, modelobj); args = Py_BuildValue("NN", nameobj, modelobj);
if (args == NULL) { if (args == NULL) {
Py_DECREF(modelobj);
flag_error(self); flag_error(self);
goto finally; 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