From eb9c1d434ba7a904410b954426800fc963986d56 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Mon, 18 Feb 2019 22:51:51 +0100 Subject: Add NULL check after native call to __html__ method If the method raises an exception, PyObject_CallObject() returns NULL, but the code didn't check for that, which led to a segfault. Fixes #108 --- src/markupsafe/_speedups.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/markupsafe/_speedups.c b/src/markupsafe/_speedups.c index 22a604d..b27435e 100644 --- a/src/markupsafe/_speedups.c +++ b/src/markupsafe/_speedups.c @@ -311,6 +311,9 @@ escape(PyObject *self, PyObject *text) if (html) { s = PyObject_CallObject(html, NULL); Py_DECREF(html); + if (s == NULL) { + return NULL; + } /* Convert to Markup object */ rv = PyObject_CallFunctionObjArgs(markup, (PyObject*)s, NULL); Py_DECREF(s); -- cgit v1.2.1