mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
[3.13] gh-139210: Fix use-after-free in xml.etree.ElementTree.iterparse() (GH-139211) (GH-139456)
(cherry picked from commit c86eb4d3ac)
Co-authored-by: Ken Jin <kenjin@python.org>
This commit is contained in:
parent
0ef302e019
commit
f48128b6b3
3 changed files with 4 additions and 1 deletions
|
|
@ -1750,6 +1750,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.
|
||||
|
|
@ -4180,8 +4180,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