summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-12-09 17:44:30 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-12-09 17:44:30 (GMT)
commita29eb08fb97fff461b62682da4ee9ac6ea8db5bf (patch)
tree3029792a7fc55bdbb4a274e70dfd4bd1a3c59131 /Modules
parentd6a69d8ccb16c1f2600e6f31edc8d156df67c9d9 (diff)
downloadcpython-a29eb08fb97fff461b62682da4ee9ac6ea8db5bf.zip
cpython-a29eb08fb97fff461b62682da4ee9ac6ea8db5bf.tar.gz
cpython-a29eb08fb97fff461b62682da4ee9ac6ea8db5bf.tar.bz2
Fixed possible leaks in ElementTree parser.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_elementtree.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 5d15ed3..915a0be 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -2935,8 +2935,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");
@@ -2944,6 +2946,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);
@@ -2951,6 +2954,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;
@@ -2958,8 +2962,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)) {