From f7bcd1d65c3435f4c3fd6ab97ffe479891463d23 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Walter=20D=C3=B6rwald?= Date: Mon, 2 Sep 2002 18:22:32 +0000 Subject: [PATCH] Check string for NULL before using it to format the error message. (Spotted by Neal Norwitz) --- Python/codecs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Python/codecs.c b/Python/codecs.c index 09cba7516c..12dfe28f84 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -465,9 +465,12 @@ static void wrong_exception_type(PyObject *exc) if (name != NULL) { PyObject *string = PyObject_Str(name); Py_DECREF(name); - PyErr_Format(PyExc_TypeError, "don't know how to handle %.400s in error callback", - PyString_AS_STRING(string)); - Py_DECREF(string); + if (string != NULL) { + PyErr_Format(PyExc_TypeError, + "don't know how to handle %.400s in error callback", + PyString_AS_STRING(string)); + Py_DECREF(string); + } } } } -- 2.40.0