summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-11-24 00:31:01 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-11-24 07:35:52 -0800
commitd0761305e645847e893799c475b2a24d15afbcd0 (patch)
tree4bf9c29f1e4325f0ddf674377267e2abb9325016 /op.c
parent58d67a2773e32367cd7f045a3afaebf08da91194 (diff)
downloadperl-d0761305e645847e893799c475b2a24d15afbcd0.tar.gz
Stop sub decl redef warnings from leaking CVs
When newMYSUB and newATTRSUB are called, PL_compcv has an unclaimed reference count, so any code that croaks must decrement the reference count or make arrangements for such to happen. This commit applies only to redefinition warnings triggered by sub declarations, like ‘sub foo {}’ and ‘my sub foo {}’.
Diffstat (limited to 'op.c')
-rw-r--r--op.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/op.c b/op.c
index addf04b30d..8efc89813c 100644
--- a/op.c
+++ b/op.c
@@ -6954,7 +6954,10 @@ S_already_defined(pTHX_ CV *const cv, OP * const block, OP * const o,
/* This ensures that warnings are reported at the first
line of a redefinition, not the last. */
CopLINE_set(PL_curcop, PL_parser->copline);
+ /* protect against fatal warnings leaking compcv */
+ SAVEFREESV(PL_compcv);
report_redefined_cv(namesv, cv, const_svp);
+ SvREFCNT_inc_simple_void_NN(PL_compcv);
CopLINE_set(PL_curcop, oldline);
}
#ifdef PERL_MAD