Discussion:
[Python-3000-checkins] r65998 - python/branches/py3k/Python/pythonrun.c
benjamin.peterson
2008-08-23 20:08:07 UTC
Permalink
Author: benjamin.peterson
Date: Sat Aug 23 22:08:07 2008
New Revision: 65998

Log:
fix #3653 Python could segfault if invalid values were passed to sys.excepthook

Author: Daniel Diniz
Reviewer: Georg Brandl


Modified:
python/branches/py3k/Python/pythonrun.c

Modified: python/branches/py3k/Python/pythonrun.c
==============================================================================
--- python/branches/py3k/Python/pythonrun.c (original)
+++ python/branches/py3k/Python/pythonrun.c Sat Aug 23 22:08:07 2008
@@ -1300,6 +1300,13 @@
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);
Neal Norwitz
2008-08-23 20:12:00 UTC
Permalink
How about a test and NEWS entry for this?

On Sat, Aug 23, 2008 at 1:08 PM, benjamin.peterson
Post by benjamin.peterson
Author: benjamin.peterson
Date: Sat Aug 23 22:08:07 2008
New Revision: 65998
fix #3653 Python could segfault if invalid values were passed to sys.excepthook
Author: Daniel Diniz
Reviewer: Georg Brandl
python/branches/py3k/Python/pythonrun.c
Modified: python/branches/py3k/Python/pythonrun.c
==============================================================================
--- python/branches/py3k/Python/pythonrun.c (original)
+++ python/branches/py3k/Python/pythonrun.c Sat Aug 23 22:08:07 2008
@@ -1300,6 +1300,13 @@
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);
_______________________________________________
Python-3000-checkins mailing list
Python-3000-checkins at python.org
http://mail.python.org/mailman/listinfo/python-3000-checkins
Loading...