mirror of https://github.com/python/cpython
Fix bug introduced by SF patch #643835, Set Next Statement for Python debuggers
blockstack_top could be 0 when blockstack[blockstack_top-1] was referenced (ie blockstack[-1]) which crashed on hpux. Patch & fix by Richie Hindle
This commit is contained in:
parent
7e4cfcb6bc
commit
ee65e22646
|
@ -184,6 +184,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case POP_BLOCK:
|
case POP_BLOCK:
|
||||||
|
assert(blockstack_top > 0);
|
||||||
setup_op = code[blockstack[blockstack_top-1]];
|
setup_op = code[blockstack[blockstack_top-1]];
|
||||||
if (setup_op == SETUP_FINALLY) {
|
if (setup_op == SETUP_FINALLY) {
|
||||||
in_finally[blockstack_top-1] = 1;
|
in_finally[blockstack_top-1] = 1;
|
||||||
|
@ -196,10 +197,13 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
|
||||||
case END_FINALLY:
|
case END_FINALLY:
|
||||||
/* Ignore END_FINALLYs for SETUP_EXCEPTs - they exist
|
/* Ignore END_FINALLYs for SETUP_EXCEPTs - they exist
|
||||||
* in the bytecode but don't correspond to an actual
|
* in the bytecode but don't correspond to an actual
|
||||||
* 'finally' block. */
|
* 'finally' block. (If blockstack_top is 0, we must
|
||||||
setup_op = code[blockstack[blockstack_top-1]];
|
* be seeing such an END_FINALLY.) */
|
||||||
if (setup_op == SETUP_FINALLY) {
|
if (blockstack_top > 0) {
|
||||||
blockstack_top--;
|
setup_op = code[blockstack[blockstack_top-1]];
|
||||||
|
if (setup_op == SETUP_FINALLY) {
|
||||||
|
blockstack_top--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -233,6 +237,10 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Verify that the blockstack tracking code didn't get lost. */
|
||||||
|
assert(blockstack_top == 0);
|
||||||
|
|
||||||
|
/* After all that, are we jumping into / out of a 'finally' block? */
|
||||||
if (new_lasti_setup_addr != f_lasti_setup_addr) {
|
if (new_lasti_setup_addr != f_lasti_setup_addr) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"can't jump into or out of a 'finally' block");
|
"can't jump into or out of a 'finally' block");
|
||||||
|
|
Loading…
Reference in New Issue