Change 19025 by [EMAIL PROTECTED] on 2003/03/18 21:59:33
Subject: [PATCH] [perl #9990] avoid goto &tmpsub coredump
From: Dave Mitchell <[EMAIL PROTECTED]>
Date: Tue, 18 Mar 2003 21:55:05 +0000
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/pp_ctl.c#349 edit
... //depot/perl/t/op/goto.t#18 edit
Differences ...
==== //depot/perl/pp_ctl.c#349 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#348~18829~ Tue Mar 4 14:23:41 2003
+++ perl/pp_ctl.c Tue Mar 18 13:59:33 2003
@@ -2203,6 +2203,7 @@
}
/* First do some returnish stuff. */
+ SvREFCNT_inc(cv); /* avoid premature free during unwind */
FREETMPS;
cxix = dopoptosub(cxstack_ix);
if (cxix < 0)
@@ -2250,6 +2251,7 @@
/* Now do some callish stuff. */
SAVETMPS;
+ SAVEFREESV(cv); /* later, undo the 'avoid premature free' hack */
if (CvXSUB(cv)) {
#ifdef PERL_XSUB_OLDSTYLE
if (CvOLDSTYLE(cv)) {
==== //depot/perl/t/op/goto.t#18 (xtext) ====
Index: perl/t/op/goto.t
--- perl/t/op/goto.t#17~18703~ Fri Feb 14 14:23:56 2003
+++ perl/t/op/goto.t Tue Mar 18 13:59:33 2003
@@ -2,7 +2,7 @@
# "This IS structured code. It's just randomly structured."
-print "1..27\n";
+print "1..28\n";
while ($?) {
$foo = 1;
@@ -176,6 +176,14 @@
print "not " unless $ok;
print "ok 27 - weird case of goto and for(;;) loop\n";
}
+
+# bug #9990 - don't prematurely free the CV we're &going to.
+
+sub f1 {
+ my $x;
+ goto sub { $x; print "ok 28 - don't prematurely free CV\n" }
+}
+f1();
exit;
End of Patch.