This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_goto: use cx->blk_oldscopesp
authorDavid Mitchell <davem@iabyn.com>
Thu, 25 Jun 2015 14:08:37 +0000 (15:08 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 08:59:32 +0000 (08:59 +0000)
POPSUB() does:

    LEAVE_SCOPE(PL_scopestack[cx->blk_oldscopesp - 1])

while pp_goto(), which manually does the relevant actions from POPSUB(),
does:

    LEAVE_SCOPE(PL_scopestack[PL_scopestack_ix - 1])

For consistency, make pp_goto() use cx->blk_oldscopesp instead.  In fact
at that point they should both hold the same value (and I've added an
assert to that effect), since we should have just popped any nested
scopes.

pp_ctl.c

index 049bffc..7cb07fa 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2746,7 +2746,8 @@ PP(pp_goto)
                CvDEPTH(cx->blk_sub.cv) = cx->blk_sub.olddepth;
                 SvREFCNT_dec_NN(cx->blk_sub.cv);
             }
-           oldsave = PL_scopestack[PL_scopestack_ix - 1];
+           assert(PL_scopestack_ix == cx->blk_oldscopesp);
+           oldsave = PL_scopestack[cx->blk_oldscopesp - 1];
            LEAVE_SCOPE(oldsave);
 
            /* A destructor called during LEAVE_SCOPE could have undefined