diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-09 17:44:30 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-09 17:44:30 (GMT) |
commit | 33ea29772deb3fbe39dba2c7b5968dced3d2ed5f (patch) | |
tree | 816a6006f35a8efa5345dce2a4aa158bbe2977c4 /Modules/_elementtree.c | |
parent | 6b93ca6a3b6e56f1ab30ff2b807f9a0e8740a470 (diff) | |
download | cpython-33ea29772deb3fbe39dba2c7b5968dced3d2ed5f.zip cpython-33ea29772deb3fbe39dba2c7b5968dced3d2ed5f.tar.gz cpython-33ea29772deb3fbe39dba2c7b5968dced3d2ed5f.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 2bf8014..2647c7b 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2227,8 +2227,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 = makestring(attrib_in[1], strlen(attrib_in[1])); @@ -2236,6 +2238,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); @@ -2243,6 +2246,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; @@ -2260,8 +2264,10 @@ expat_start_handler(XMLParserObject* self, const XML_Char* tag_in, if (attrib == Py_None) { Py_DECREF(attrib); attrib = PyDict_New(); - if (!attrib) + if (!attrib) { + Py_DECREF(tag); return; + } } res = PyObject_CallFunction(self->handle_start, "OO", tag, attrib); } else |