Fix a crash in _elementtree related to lone unicode surrogates.

Fix a segfault on:

   >>> import _elementtree
   >>> _elementtree.iterparse('/bin/sh', ("\uDC80", "\ud808\udf45"))
This commit is contained in:
Victor Stinner 2010-03-22 12:11:44 +00:00
parent eab4b4c784
commit 0477bf3a93
1 changed files with 2 additions and 0 deletions

View File

@ -2734,6 +2734,8 @@ xmlparser_setevents(XMLParserObject* self, PyObject* args)
char* event;
if (PyUnicode_Check(item)) {
event = _PyUnicode_AsString(item);
if (event == NULL)
goto error;
} else if (PyBytes_Check(item))
event = PyBytes_AS_STRING(item);
else {