python-segfault-fix.patch (1332B)
1 Upstream: https://bugzilla.gnome.org/show_bug.cgi?id=791691 2 3 From d1ea6250dd00a3b7a92b52a743ec53f7751196e5 Mon Sep 17 00:00:00 2001 4 From: "A. Wilcox" <AWilcox@Wilcox-Tech.com> 5 Date: Sat, 16 Dec 2017 19:22:23 -0600 6 Subject: [PATCH] Python: if message is NULL, use Py_None instead 7 8 If the error message is malformed / invalid UTF-8, and the Python 3 9 binding is being used, then message may be NULL. This will cause the 10 Python interpreter to crash (Segmentation fault) trying to unpack the 11 argument list into local variables. 12 13 This uses Py_None for message if message is NULL, so that the 14 interpreter does not crash. 15 --- 16 python/libxml.c | 4 ++++ 17 1 file changed, 4 insertions(+) 18 19 diff --git a/python/libxml.c b/python/libxml.c 20 index 5b1ff6e8..dae77b88 100644 21 --- a/python/libxml.c 22 +++ b/python/libxml.c 23 @@ -1640,6 +1640,10 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, const char *msg, 24 PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt); 25 Py_XINCREF(libxml_xmlPythonErrorFuncCtxt); 26 message = libxml_charPtrConstWrap(str); 27 + if (message == NULL) { 28 + Py_INCREF(Py_None); 29 + message = Py_None; 30 + } 31 PyTuple_SetItem(list, 1, message); 32 result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list); 33 Py_XDECREF(list); 34 -- 35 2.14.1 36