diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-11-24 00:31:01 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-11-24 07:35:52 -0800 |
commit | d0761305e645847e893799c475b2a24d15afbcd0 (patch) | |
tree | 4bf9c29f1e4325f0ddf674377267e2abb9325016 /op.c | |
parent | 58d67a2773e32367cd7f045a3afaebf08da91194 (diff) | |
download | perl-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.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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 |