diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-09 17:45:07 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-09 17:45:07 (GMT) |
commit | 956244bee1f97a0a86de2c33d803f49db2214450 (patch) | |
tree | 04e718bc9149db5863f74e8dd4be7b2cf5f9018d /Modules/_elementtree.c | |
parent | 9fcbdf480e03c8bfd2aa17f5f1113c904659d431 (diff) | |
parent | a29eb08fb97fff461b62682da4ee9ac6ea8db5bf (diff) | |
download | cpython-956244bee1f97a0a86de2c33d803f49db2214450.zip cpython-956244bee1f97a0a86de2c33d803f49db2214450.tar.gz cpython-956244bee1f97a0a86de2c33d803f49db2214450.tar.bz2 |
Fixed possible leaks in ElementTree parser.
Diffstat (limited to 'Modules/_elementtree.c')
-rw-r--r-- | Modules/_elementtree.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index 666065a..3cf3d59 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2934,8 +2934,10 @@ expat_start_handler(XMLParserObject* self, const XML_Char* tag_in, /* attributes */ if (attrib_in[0]) { attrib = PyDict_New(); - if (!attrib) + if (!attrib) { + Py_DECREF(tag); return; + } while (attrib_in[0] && attrib_in[1]) { PyObject* key = makeuniversal(self, attrib_in[0]); PyObject* value = PyUnicode_DecodeUTF8(attrib_in[1], strlen(attrib_in[1]), "strict"); @@ -2943,6 +2945,7 @@ expat_start_handler(XMLParserObject* self, const XML_Char* tag_in, Py_XDECREF(value); Py_XDECREF(key); Py_DECREF(attrib); + Py_DECREF(tag); return; } ok = PyDict_SetItem(attrib, key, value); @@ -2950,6 +2953,7 @@ expat_start_handler(XMLParserObject* self, const XML_Char* tag_in, Py_DECREF(key); if (ok < 0) { Py_DECREF(attrib); + Py_DECREF(tag); return; } attrib_in += 2; @@ -2957,8 +2961,10 @@ expat_start_handler(XMLParserObject* self, const XML_Char* tag_in, } else { /* Pass an empty dictionary on */ attrib = PyDict_New(); - if (!attrib) + if (!attrib) { + Py_DECREF(tag); return; + } } if (TreeBuilder_CheckExact(self->target)) { |