diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-12-09 06:24:21 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-12-09 06:24:36 -0800 |
commit | c4c855b90ec42b2452daf44d4d9994afd1613089 (patch) | |
tree | f3af93eb31e12e2eaef6a0b8a4c846d18c30d354 /op.c | |
parent | 74a9453a18ff8c4f52f48455c0b4a622e295160a (diff) | |
download | perl-c4c855b90ec42b2452daf44d4d9994afd1613089.tar.gz |
op.c: Temporary fix for bad read
We can’t read *name at this point, because the
SAVEFREEOP(o)/LEAVE_SCOPE above will have freed the SV owning the
string buffer.
We can’t do pad_add_weakref before LEAVE_SCOPE, because it will add
the entry to the wrong pad.
This fix is only temporary, because one more behaviour change (ena-
bling read-only ops for special blocks other than BEGIN) will allow be
to simplify it.
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -8450,6 +8450,7 @@ Perl_newATTRSUB_x(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, bool has_name; bool name_is_utf8 = o && !o_is_gv && SvUTF8(cSVOPo->op_sv); bool special = FALSE; + bool maybe_begin = FALSE; OP *start; #ifdef PERL_DEBUG_READONLY_OPS OPSLAB *slab = NULL; @@ -8856,8 +8857,11 @@ Perl_newATTRSUB_x(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, if (PL_parser && PL_parser->error_count) clear_special_blocks(name, gv, cv); else + { + maybe_begin = *name == 'B'; special = process_special_blocks(floor, name, gv, cv); + } } } @@ -8870,7 +8874,7 @@ Perl_newATTRSUB_x(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, if (!special && slab) Slab_to_ro(slab); #endif - if (cv && name && (!special || *name != 'B') && CvOUTSIDE(cv) + if (cv && name && (!special || !maybe_begin) && CvOUTSIDE(cv) && !CvEVAL(CvOUTSIDE(cv))) pad_add_weakref(cv); return cv; |