summaryrefslogtreecommitdiff
path: root/Modules/_elementtree.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-12-09 11:27:34 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2015-12-09 11:27:34 +0200
commit8103d5774a40c138619a1d103b82473b67234887 (patch)
treef7b5086f7fe29792ee93feecbe2291120fd1b2be /Modules/_elementtree.c
parentaa9635ffc60c99451c0aa9afb5746a116911a89c (diff)
parentf9be53edd76d67976e3c2594471c6c49e0e298e9 (diff)
downloadcpython-8103d5774a40c138619a1d103b82473b67234887.tar.gz
Fixed possible leak in ElementTree.Element.iter().
Diffstat (limited to 'Modules/_elementtree.c')
-rw-r--r--Modules/_elementtree.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 168c7d6d47..666065ae31 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -1373,6 +1373,17 @@ static PyObject *
_elementtree_Element_iter_impl(ElementObject *self, PyObject *tag)
/*[clinic end generated code: output=3f49f9a862941cc5 input=774d5b12e573aedd]*/
{
+ if (PyUnicode_Check(tag)) {
+ if (PyUnicode_READY(tag) < 0)
+ return NULL;
+ if (PyUnicode_GET_LENGTH(tag) == 1 && PyUnicode_READ_CHAR(tag, 0) == '*')
+ tag = Py_None;
+ }
+ else if (PyBytes_Check(tag)) {
+ if (PyBytes_GET_SIZE(tag) == 1 && *PyBytes_AS_STRING(tag) == '*')
+ tag = Py_None;
+ }
+
return create_elementiter(self, tag, 0);
}
@@ -2236,17 +2247,6 @@ create_elementiter(ElementObject *self, PyObject *tag, int gettext)
if (!it)
return NULL;
- if (PyUnicode_Check(tag)) {
- if (PyUnicode_READY(tag) < 0)
- return NULL;
- if (PyUnicode_GET_LENGTH(tag) == 1 && PyUnicode_READ_CHAR(tag, 0) == '*')
- tag = Py_None;
- }
- else if (PyBytes_Check(tag)) {
- if (PyBytes_GET_SIZE(tag) == 1 && *PyBytes_AS_STRING(tag) == '*')
- tag = Py_None;
- }
-
Py_INCREF(tag);
it->sought_tag = tag;
it->root_done = 0;