This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
[perl5.git] / pad.c
diff --git a/pad.c b/pad.c
index 772a494..9528d84 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -256,14 +256,17 @@ Perl_pad_undef(pTHX_ CV* cv)
                && *SvPVX(namesv) == '&')
            {
                CV * const innercv = (CV*)curpad[ix];
+               U32 inner_rc = SvREFCNT(innercv);
+               assert(inner_rc);
                namepad[ix] = Nullsv;
                SvREFCNT_dec(namesv);
 
                if (SvREFCNT(comppad) < 2) { /* allow for /(?{ sub{} })/  */
                    curpad[ix] = Nullsv;
                    SvREFCNT_dec(innercv);
+                   inner_rc--;
                }
-               if (SvREFCNT(innercv) /* in use, not just a prototype */
+               if (inner_rc /* in use, not just a prototype */
                    && CvOUTSIDE(innercv) == cv)
                {
                    assert(CvWEAKOUTSIDE(innercv));