summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-11-13 14:52:09 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-11-13 14:54:21 -0800
commit4d2dfd152adb9e89694e8af7f0ae810bda03128b (patch)
tree09b1ccf5634a247c263ad6ea8d51831ca312fd84 /op.c
parente1ff3a882ff0ab24ec23467b3cd86bf1a249d61a (diff)
downloadperl-4d2dfd152adb9e89694e8af7f0ae810bda03128b.tar.gz
Fix assertion failures with anon subs
In commit 9ffcdca1f50, I did not take into account that the newATTRSUB’s caller makes sure that the CV is freed if it is an anonymous sub. So I only needed to free the sub explicitly after a syntax error for a named sub. By returning 0 for anonymous subs as well, I ended up causing assertion failures. Why I wasn’t getting them before I don’t know, as I was using a debugging build.
Diffstat (limited to 'op.c')
-rw-r--r--op.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/op.c b/op.c
index b2801c7b5f..d7bf037c5c 100644
--- a/op.c
+++ b/op.c
@@ -4650,7 +4650,7 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, bool isreg, I32 floor)
/* attach the anon CV to the pad so that
* pad_fixup_inner_anons() can find it */
- if (cv) (void)pad_add_anon(cv, o->op_type);
+ (void)pad_add_anon(cv, o->op_type);
SvREFCNT_inc_simple_void(cv);
}
else {
@@ -7370,7 +7370,8 @@ Perl_newATTRSUB_flags(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs,
if (ec) {
op_free(block);
- SvREFCNT_dec(PL_compcv);
+ if (name) SvREFCNT_dec(PL_compcv);
+ else cv = PL_compcv;
PL_compcv = 0;
if (name && block) {
const char *s = strrchr(name, ':');
@@ -8175,9 +8176,6 @@ Perl_ck_anoncode(pTHX_ OP *o)
{
PERL_ARGS_ASSERT_CK_ANONCODE;
- /* After errors, we won’t have any sub. */
- if (!cSVOPo->op_sv) return o;
-
cSVOPo->op_targ = pad_add_anon((CV*)cSVOPo->op_sv, o->op_type);
if (!PL_madskills)
cSVOPo->op_sv = NULL;