pad.c:cv_clone: add assertions
authorFather Chrysostomos <sprout@cpan.org>
Sun, 5 Aug 2012 00:54:32 +0000 (17:54 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 5 Aug 2012 00:54:32 +0000 (17:54 -0700)
The outer sub should always be active and have a pad if it is
a sub that is being cloned.  Only formats can have an inactive or
padless outside.  Add assertions to that effect.

pad.c

diff --git a/pad.c b/pad.c
index 1e796e7..8deae8e 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -2010,6 +2010,7 @@ Perl_cv_clone(pTHX_ CV *proto)
     outpad = CvPADLIST(outside)
        ? AvARRAY(AvARRAY(CvPADLIST(outside))[depth])
        : NULL;
+    assert(outpad || SvTYPE(cv) == SVt_PVFM);
 
     for (ix = fpad; ix > 0; ix--) {
        SV* const namesv = (ix <= fname) ? pname[ix] : NULL;
@@ -2022,6 +2023,7 @@ Perl_cv_clone(pTHX_ CV *proto)
                if (!outpad || !(sv = outpad[PARENT_PAD_INDEX(namesv)])
                 || (  SvPADSTALE(sv) && !SvPAD_STATE(namesv)
                    && !CvDEPTH(outside))  ) {
+                   assert(SvTYPE(cv) == SVt_PVFM);
                    Perl_ck_warner(aTHX_ packWARN(WARN_CLOSURE),
                                   "Variable \"%"SVf"\" is not available", namesv);
                    sv = NULL;