From: Benjamin Peterson Date: Sat, 23 Aug 2008 20:08:07 +0000 (+0000) Subject: fix #3653 Python could segfault if invalid values were passed to sys.excepthook X-Git-Tag: v3.0rc1~186 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2658260f3b4984b03e60cc5856e1203e0cd1f807;p=python fix #3653 Python could segfault if invalid values were passed to sys.excepthook Author: Daniel Diniz Reviewer: Georg Brandl --- diff --git a/Python/pythonrun.c b/Python/pythonrun.c index a1777bd5b2..1ee062fe6f 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1300,6 +1300,13 @@ print_exception(PyObject *f, PyObject *value) int err = 0; PyObject *type, *tb; + if (!PyExceptionInstance_Check(value)) { + PyFile_WriteString("TypeError: print_exception(): Exception expected for value, ", f); + PyFile_WriteString(Py_TYPE(value)->tp_name, f); + PyFile_WriteString(" found\n", f); + return; + } + Py_INCREF(value); fflush(stdout); type = (PyObject *) Py_TYPE(value);