Skip to content

Commit 504d203

Browse files
iabyndemerphq
authored andcommitted
Perl_deb_stack_all() - handle empty CX stack
This function handles perl -Dsv, producing output like STACK 0: MAIN CX 0: BLOCK => CX 1: SUB => UNDEF PV("main"\0) retop=leave STACK 1: MAGIC CX 0: SUB => IV(1) When a CX stack had zero contexts pushed (like can sometimes happen when something has just done a PUSHSTACKi() and no op has pushed a BLOCK or SUB or whatever yet), then the code for determining where the next markstack pointer is (by peeking ahead into the first CX of the next SI) was accessing random garbage at cx[0]. This commit fixes that.
1 parent 043a585 commit 504d203

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

deb.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,10 @@ Perl_deb_stack_all(pTHX)
320320
}
321321
if (CxTYPE(&(si_n->si_cxstack[i])) == CXt_SUBST)
322322
continue;
323-
cx_n = &(si_n->si_cxstack[i]);
323+
if (si_n->si_cxix >= 0)
324+
cx_n = &(si_n->si_cxstack[i]);
325+
else
326+
cx_n = NULL;
324327
break;
325328
}
326329

0 commit comments

Comments
 (0)