summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-09-26 19:24:45 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-09-26 19:24:45 (GMT)
commitc631489289145041c310a7a06caf498eeb49a5d2 (patch)
tree6890cb3ae7d4bf675d3b47b66613c2c2b7864816
parent479384e1ff19cd9987ee89c64fb33030797b44f3 (diff)
downloadcpython-c631489289145041c310a7a06caf498eeb49a5d2.zip
cpython-c631489289145041c310a7a06caf498eeb49a5d2.tar.gz
cpython-c631489289145041c310a7a06caf498eeb49a5d2.tar.bz2
Prevent a NULL pointer from being pushed onto the stack.
It's possible for PyErr_NormalizeException() to set the traceback pointer to NULL. I'm not sure how to provoke this directly from Python, although it may be possible. The error occurs when an exception is set using PyErr_SetObject() and another exception occurs while PyErr_NormalizeException() is creating the exception instance. XXX As a result of this change, it's possible for an exception to occur but sys.last_traceback to be left undefined. Not sure if this is a problem.
-rw-r--r--Python/ceval.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 5a8f503..731e93f 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2255,7 +2255,11 @@ eval_frame(PyFrameObject *f)
set_exc_info(tstate,
exc, val, tb);
}
- PUSH(tb);
+ if (tb == NULL) {
+ Py_INCREF(Py_None);
+ PUSH(Py_None);
+ } else
+ PUSH(tb);
PUSH(val);
PUSH(exc);
}