Patch #1309009, Fix segfault in pyexpat when the XML document is
in latin_1, but Python incorrectly assumes it is in UTF-8 format
Will backport.
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index e6c14f8..438f760 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -417,6 +417,9 @@
{
PyObject *result = STRING_CONV_FUNC(str);
PyObject *value;
+ /* result can be NULL if the unicode conversion failed. */
+ if (!result)
+ return result;
if (!self->intern)
return result;
value = PyDict_GetItem(self->intern, result);
@@ -572,7 +575,9 @@
Py_DECREF(v);
}
}
- args = Py_BuildValue("(NN)", string_intern(self, name), container);
+ args = string_intern(self, name);
+ if (args != NULL)
+ args = Py_BuildValue("(NN)", args, container);
if (args == NULL) {
Py_DECREF(container);
return;