pad.c:pad_fixup_inner_anons: Add assertions
authorFather Chrysostomos <sprout@cpan.org>
Sat, 10 Sep 2016 14:27:43 +0000 (07:27 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 10 Sep 2016 21:11:19 +0000 (14:11 -0700)
These would have made it easier to track down the bug fixed by
the previous commit.

pad.c

diff --git a/pad.c b/pad.c
index a41d2c7..7cf1fe3 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -2376,6 +2376,7 @@ Perl_pad_fixup_inner_anons(pTHX_ PADLIST *padlist, CV *old_cv, CV *new_cv)
            PADNAME **names = namepad;
            PADOFFSET i = ix;
            while (PadnameOUTER(name)) {
+               assert(SvTYPE(cv) == SVt_PVCV);
                cv = CvOUTSIDE(cv);
                names = PadlistNAMESARRAY(CvPADLIST(cv));
                i = PARENT_PAD_INDEX(name);
@@ -2406,6 +2407,7 @@ Perl_pad_fixup_inner_anons(pTHX_ PADLIST *padlist, CV *old_cv, CV *new_cv)
            assert(SvWEAKREF(rv));
            innercv = (CV *)SvRV(rv);
            assert(!CvWEAKOUTSIDE(innercv));
+           assert(CvOUTSIDE(innercv) == old_cv);
            SvREFCNT_dec(CvOUTSIDE(innercv));
            CvOUTSIDE(innercv) = (CV *)SvREFCNT_inc_simple_NN(new_cv);
          }