diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-09 09:27:34 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-09 09:27:34 (GMT) |
commit | 9fcbdf480e03c8bfd2aa17f5f1113c904659d431 (patch) | |
tree | ea2e07bae25905b14be28a42bce647e90af58f92 | |
parent | e0ffe17e72253429eca94664d5b870f643a2a6dc (diff) | |
parent | d6a69d8ccb16c1f2600e6f31edc8d156df67c9d9 (diff) | |
download | cpython-9fcbdf480e03c8bfd2aa17f5f1113c904659d431.zip cpython-9fcbdf480e03c8bfd2aa17f5f1113c904659d431.tar.gz cpython-9fcbdf480e03c8bfd2aa17f5f1113c904659d431.tar.bz2 |
Fixed possible leak in ElementTree.Element.iter().
-rw-r--r-- | Modules/_elementtree.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index 168c7d6..666065a 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; |