diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-10-19 00:26:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-19 00:26:37 -0700 |
commit | 5744a3362945e0d9cd7bb24ed5ebcedba8822d4c (patch) | |
tree | cedf0f81508fc08d39ba8ffa9b8d84edf6f93c4b /Modules | |
parent | 6e57382464101d2669a425622e19fff57586b2ff (diff) | |
download | cpython-git-5744a3362945e0d9cd7bb24ed5ebcedba8822d4c.tar.gz |
Fix several reference counting bugs in pyexpat.c. (GH-9955)
(cherry picked from commit 68def052dcd41313eff2bd9f269e22c5a941db4d)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/pyexpat.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index 1f8c0d70a5..bbda6ffd02 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -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; } |