&& CvOUTSIDE(innercv) == cv)
{
assert(CvWEAKOUTSIDE(innercv));
- CvWEAKOUTSIDE_off(innercv);
- CvOUTSIDE(innercv) = outercv;
- CvOUTSIDE_SEQ(innercv) = seq;
- SvREFCNT_inc(outercv);
+ /* don't relink to grandfather if he's being freed */
+ if (outercv && SvREFCNT(outercv)) {
+ CvWEAKOUTSIDE_off(innercv);
+ CvOUTSIDE(innercv) = outercv;
+ CvOUTSIDE_SEQ(innercv) = seq;
+ SvREFCNT_inc(outercv);
+ }
+ else {
+ CvOUTSIDE(innercv) = Nullcv;
+ }
+
}
+
}
}
}
use Config;
-print "1..184\n";
+print "1..185\n";
my $test = 1;
sub test (&) {
test { $a{7}->()->() + $a{11}->()->() == 18 };
}
+# bugid #23265 - this used to coredump during destruction of PL_maincv
+# and its children
+
+require './test.pl';
+
+my $got = runperl(
+ prog => q[
+ print
+ sub {$_[0]->(@_)} -> (
+ sub {
+ $_[1]
+ ? $_[0]->($_[0], $_[1] - 1) . sub {"x"}->()
+ : "y"
+ },
+ 2
+ )
+ , "\n"
+ ;
+
+ ],
+ stderr => 1
+);
+test { $got eq "yxx\n" };