Skip to content

Commit afbd201

Browse files
author
doerwalter
committed
Check string for NULL before using it to format the error message.
(Spotted by Neal Norwitz) git-svn-id: http://svn.python.org/projects/python/trunk@28522 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 1dc5a3c commit afbd201

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Python/codecs.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,12 @@ static void wrong_exception_type(PyObject *exc)
465465
if (name != NULL) {
466466
PyObject *string = PyObject_Str(name);
467467
Py_DECREF(name);
468-
PyErr_Format(PyExc_TypeError, "don't know how to handle %.400s in error callback",
469-
PyString_AS_STRING(string));
470-
Py_DECREF(string);
468+
if (string != NULL) {
469+
PyErr_Format(PyExc_TypeError,
470+
"don't know how to handle %.400s in error callback",
471+
PyString_AS_STRING(string));
472+
Py_DECREF(string);
473+
}
471474
}
472475
}
473476
}

0 commit comments

Comments
 (0)