mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Fixed possible leak in ElementTree.Element.iter().
This commit is contained in:
parent
3181feb601
commit
d6a69d8ccb
1 changed files with 11 additions and 11 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -2238,17 +2249,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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue