Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c631489

Browse files
committed
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.
1 parent 479384e commit c631489

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Python/ceval.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,11 @@ eval_frame(PyFrameObject *f)
22552255
set_exc_info(tstate,
22562256
exc, val, tb);
22572257
}
2258-
PUSH(tb);
2258+
if (tb == NULL) {
2259+
Py_INCREF(Py_None);
2260+
PUSH(Py_None);
2261+
} else
2262+
PUSH(tb);
22592263
PUSH(val);
22602264
PUSH(exc);
22612265
}

0 commit comments

Comments
 (0)