1
Submitted By: Pierre Labastie <pierre dot labastie at neuf dot fr>
3
Initial Package Version: 2.9.7
4
Upstream Status: Bug reported (https://bugzilla.gnome.org/show_bug.cgi?id=789714)
5
Origin: Jan Majetek/OpenSuse (https://bugzilla.opensuse.org/show_bug.cgi?id=1065270)
6
Description: Fix a segfault in the Python 3 module. It is only a hack.
8
Index: libxml2-2.9.5/python/libxml.c
9
===================================================================
10
--- libxml2-2.9.5.orig/python/libxml.c
11
+++ libxml2-2.9.5/python/libxml.c
12
@@ -1620,6 +1620,7 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
16
+ unsigned char *ptr = (unsigned char *)str;
19
printf("libxml_xmlErrorFuncHandler(%p, %s, ...) called\n", ctx, msg);
20
@@ -1636,12 +1637,20 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
24
+#if PY_MAJOR_VERSION >= 3
25
+ /* Ensure the error string doesn't start at UTF8 continuation. */
26
+ while (*ptr && (*ptr & 0xc0) == 0x80)
30
list = PyTuple_New(2);
31
PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt);
32
Py_XINCREF(libxml_xmlPythonErrorFuncCtxt);
33
- message = libxml_charPtrConstWrap(str);
34
+ message = libxml_charPtrConstWrap(ptr);
35
PyTuple_SetItem(list, 1, message);
36
result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list);
37
+ /* Forget any errors caused in the error handler. */