1. Mark Shannon
  2. hotpy_2

Commits

Mark Shannon  committed b7a7b95 Draft

Ensure NULL is not pushed to stack

  • Participants
  • Parent commits 09b5a1e
  • Branches default

Comments (0)

Files changed (1)

File Python/ceval.c

View file
                 int handler = b->b_handler;
                 /* Beware, this invalidates all b->b_* fields */
                 PyFrame_BlockSetup(f, EXCEPT_HANDLER, -1, STACK_LEVEL());
-                PUSH(tstate->exc_traceback);
-                PUSH(tstate->exc_value);
+                if (tstate->exc_traceback != NULL) {
+                    PUSH(tstate->exc_traceback);
+                }
+                else {
+                    Py_INCREF(Py_None);
+                    PUSH(Py_None);
+                }
+                if (tstate->exc_value != NULL) {
+                    PUSH(tstate->exc_value);
+                }
+                else {
+                    Py_INCREF(Py_None);
+                    PUSH(Py_None);
+                }
                 if (tstate->exc_type != NULL) {
                     PUSH(tstate->exc_type);
                 }