From: Dave Bailey Date: Tue, 17 Oct 2006 09:37:28 +0000 (-0700) Subject: [perl #40557] regexec.c saves context stack position improperly X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ea8d6ae1f062ab3b10e0ad05f17970dead9860ff;p=p5sagit%2Fp5-mst-13.2.git [perl #40557] regexec.c saves context stack position improperly From: Dave Bailey (via RT) Message-ID: p4raw-id: //depot/perl@29033 --- diff --git a/regexec.c b/regexec.c index 30dd354..c4d88cc 100644 --- a/regexec.c +++ b/regexec.c @@ -2094,7 +2094,7 @@ S_regtry(pTHX_ const regmatch_info *reginfo, char *startpos) PerlIO_printf(Perl_debug_log, " setting stack tmpbase at %"IVdf"\n", (IV)(PL_stack_sp - PL_stack_base)); )); - SAVEI32(cxstack[cxstack_ix].blk_oldsp); + SAVESTACK_CXPOS(); cxstack[cxstack_ix].blk_oldsp = PL_stack_sp - PL_stack_base; /* Otherwise OP_NEXTSTATE will free whatever on stack now. */ SAVETMPS; diff --git a/scope.c b/scope.c index 8923104..6a996ce 100644 --- a/scope.c +++ b/scope.c @@ -831,6 +831,10 @@ Perl_leave_scope(pTHX_ I32 base) i = SSPOPINT; PL_stack_sp = PL_stack_base + i; break; + case SAVEt_STACK_CXPOS: /* blk_oldsp on context stack */ + i = SSPOPINT; + cxstack[i].blk_oldsp = SSPOPINT; + break; case SAVEt_AELEM: /* array element */ value = (SV*)SSPOPPTR; i = SSPOPINT; diff --git a/scope.h b/scope.h index 9943a05..377a8b4 100644 --- a/scope.h +++ b/scope.h @@ -52,6 +52,7 @@ #define SAVEt_COP_ARYBASE 41 #define SAVEt_RE_STATE 42 #define SAVEt_COMPILE_WARNINGS 43 +#define SAVEt_STACK_CXPOS 44 #ifndef SCOPE_SAVES_SIGNAL_MASK #define SCOPE_SAVES_SIGNAL_MASK 0 @@ -205,6 +206,14 @@ Closing bracket on a callback. See C and L. SSPUSHINT(SAVEt_COMPILE_WARNINGS); \ } STMT_END +#define SAVESTACK_CXPOS() \ + STMT_START { \ + SSCHECK(3); \ + SSPUSHINT(cxstack[cxstack_ix].blk_oldsp); \ + SSPUSHINT(cxstack_ix); \ + SSPUSHINT(SAVEt_STACK_CXPOS); \ + } STMT_END + #ifdef USE_ITHREADS # define SAVECOPSTASH(c) SAVEPPTR(CopSTASHPV(c)) # define SAVECOPSTASH_FREE(c) SAVESHAREDPV(CopSTASHPV(c))