mirror of
https://github.com/python/cpython.git
synced 2026-01-04 14:32:21 +00:00
gh-139210: Fix use-after-free in xml.etree.ElementTree.iterparse() (GH-139211)
This commit is contained in:
parent
f752fde452
commit
c86eb4d3ac
3 changed files with 4 additions and 1 deletions
|
|
@ -1749,6 +1749,8 @@ def __next__(self):
|
|||
def test_unknown_event(self):
|
||||
with self.assertRaises(ValueError):
|
||||
ET.XMLPullParser(events=('start', 'end', 'bogus'))
|
||||
with self.assertRaisesRegex(ValueError, "unknown event 'bogus'"):
|
||||
ET.XMLPullParser(events=(x.decode() for x in (b'start', b'end', b'bogus')))
|
||||
|
||||
@unittest.skipIf(pyexpat.version_info < (2, 6, 0),
|
||||
f'Expat {pyexpat.version_info} does not '
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Fix use-after-free when reporting unknown event in :func:`xml.etree.ElementTree.iterparse`. Patch by Ken Jin.
|
||||
|
|
@ -4214,8 +4214,8 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self,
|
|||
(XML_ProcessingInstructionHandler) expat_pi_handler
|
||||
);
|
||||
} else {
|
||||
Py_DECREF(events_seq);
|
||||
PyErr_Format(PyExc_ValueError, "unknown event '%s'", event_name);
|
||||
Py_DECREF(events_seq);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue