Mercurial > cpython-lru_cache-weakref
diff Python/codecs.c @ 25095:1b80e0fd5a48 legacy-trunk
Check string for NULL before using it to format the error message.
(Spotted by Neal Norwitz)
| author | Walter Dörwald <walter@livinglogic.de> |
|---|---|
| date | Mon, 02 Sep 2002 18:22:32 +0000 |
| parents | 0337dad8403e |
| children | d32588c88633 |
line wrap: on
line diff
--- a/Python/codecs.c Mon Sep 02 16:41:55 2002 +0000 +++ b/Python/codecs.c Mon Sep 02 18:22:32 2002 +0000 @@ -465,9 +465,12 @@ 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); + } } } }
