commit:     da4038c33b2c7684f5766d6e8f1d1089e863e87c
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Dec  3 00:13:24 2020 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Dec  3 00:14:49 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=da4038c3

dev-libs/libxml2: restore itstool-segfault patch

We stopped applying this patch during a roll
of a new patchset (my fault), but it seems to still
be needed. Noticed when building some of MATE.

Bug: https://bugs.gentoo.org/745162
Package-Manager: Portage-3.0.9, Repoman-3.0.2
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../libxml2-2.9.8-python3-unicode-errors.patch     | 34 ++++++++++++++++++++++
 ...2-2.9.10-r3.ebuild => libxml2-2.9.10-r4.ebuild} |  3 ++
 2 files changed, 37 insertions(+)

diff --git a/dev-libs/libxml2/files/libxml2-2.9.8-python3-unicode-errors.patch 
b/dev-libs/libxml2/files/libxml2-2.9.8-python3-unicode-errors.patch
new file mode 100644
index 00000000000..e87dcdedf88
--- /dev/null
+++ b/dev-libs/libxml2/files/libxml2-2.9.8-python3-unicode-errors.patch
@@ -0,0 +1,34 @@
+Index: libxml2-2.9.5/python/libxml.c
+===================================================================
+--- libxml2-2.9.5.orig/python/libxml.c
++++ libxml2-2.9.5/python/libxml.c
+@@ -1620,6 +1620,7 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
+     PyObject *message;
+     PyObject *result;
+     char str[1000];
++    unsigned char *ptr = (unsigned char *)str;
+ 
+ #ifdef DEBUG_ERROR
+     printf("libxml_xmlErrorFuncHandler(%p, %s, ...) called\n", ctx, msg);
+@@ -1636,12 +1637,20 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
+           str[999] = 0;
+         va_end(ap);
+ 
++#if PY_MAJOR_VERSION >= 3
++        /* Ensure the error string doesn't start at UTF8 continuation. */
++        while (*ptr && (*ptr & 0xc0) == 0x80)
++            ptr++;
++#endif
++
+         list = PyTuple_New(2);
+         PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt);
+         Py_XINCREF(libxml_xmlPythonErrorFuncCtxt);
+-        message = libxml_charPtrConstWrap(str);
++        message = libxml_charPtrConstWrap(ptr);
+         PyTuple_SetItem(list, 1, message);
+         result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list);
++        /* Forget any errors caused in the error handler. */
++        PyErr_Clear();
+         Py_XDECREF(list);
+         Py_XDECREF(result);
+     }

diff --git a/dev-libs/libxml2/libxml2-2.9.10-r3.ebuild 
b/dev-libs/libxml2/libxml2-2.9.10-r4.ebuild
similarity index 98%
rename from dev-libs/libxml2/libxml2-2.9.10-r3.ebuild
rename to dev-libs/libxml2/libxml2-2.9.10-r4.ebuild
index 916abdd469c..a6678320ffe 100644
--- a/dev-libs/libxml2/libxml2-2.9.10-r3.ebuild
+++ b/dev-libs/libxml2/libxml2-2.9.10-r4.ebuild
@@ -93,6 +93,9 @@ src_prepare() {
        # Fix python tests when building out of tree #565576
        eapply "${FILESDIR}"/${PN}-2.9.8-out-of-tree-test.patch
 
+       # bug #745162
+       eapply "${FILESDIR}"/${PN}-2.9.8-python3-unicode-errors.patch
+
        if [[ ${CHOST} == *-darwin* ]] ; then
                # Avoid final linking arguments for python modules
                sed -i -e '/PYTHON_LIBS/s/ldflags/libs/' configure.ac || die

Reply via email to