[perl #124099] Wrong CvOUTSIDE in find_lexical_cv
authorFather Chrysostomos <sprout@cpan.org>
Fri, 27 Mar 2015 19:39:54 +0000 (12:39 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 27 Mar 2015 19:39:54 +0000 (12:39 -0700)
Instead of following the chain of CvOUTSIDE pointers, I had it always
looking at the CvOUTSIDE pointer of the current PL_compcv.  So any
time it had to dig down more than one level, it had a chance of crash-
ing or looping.

op.c
t/op/lexsub.t

diff --git a/op.c b/op.c
index 89bf436..3000c44 100644 (file)
--- a/op.c
+++ b/op.c
@@ -11238,7 +11238,7 @@ Perl_find_lexical_cv(pTHX_ PADOFFSET off)
     CV *compcv = PL_compcv;
     while (PadnameOUTER(name)) {
        assert(PARENT_PAD_INDEX(name));
-       compcv = CvOUTSIDE(PL_compcv);
+       compcv = CvOUTSIDE(compcv);
        name = PadlistNAMESARRAY(CvPADLIST(compcv))
                [off = PARENT_PAD_INDEX(name)];
     }
index b1b76e8..adccf4c 100644 (file)
@@ -961,3 +961,9 @@ like runperl(
   @AutoloadTest::ISA = AutoloadTestSuper::;
   AutoloadTest->blah;
 }
+
+# This used to crash because op.c:find_lexical_cv was looking at the wrong
+# CV’s OUTSIDE pointer.  [perl #124099]
+{
+  my sub h; sub{my $x; sub{h}}
+}