summaryrefslogtreecommitdiff
path: root/t/op/loopctl.t
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2004-03-04 23:32:38 +0000
committerDave Mitchell <davem@fdisolutions.com>2004-03-04 23:32:38 +0000
commit936c78b5fbfb4bf020fdea54970ee48649babcc3 (patch)
tree46a57f731ab8c3b39318da3028ea2df820eacbd2 /t/op/loopctl.t
parent4ccc72b7cccd09b4aef23610849d9be0320655b6 (diff)
downloadperl-936c78b5fbfb4bf020fdea54970ee48649babcc3.tar.gz
[perl #27206] Memory leak in continue loop
make sure redo always frees temps p4raw-id: //depot/perl@22438
Diffstat (limited to 't/op/loopctl.t')
-rw-r--r--t/op/loopctl.t25
1 files changed, 24 insertions, 1 deletions
diff --git a/t/op/loopctl.t b/t/op/loopctl.t
index 2ed9df1432..bc326c7b1a 100644
--- a/t/op/loopctl.t
+++ b/t/op/loopctl.t
@@ -31,7 +31,7 @@
#
# -- .robin. <robin@kitsite.com> 2001-03-13
-print "1..41\n";
+print "1..43\n";
my $ok;
@@ -944,3 +944,26 @@ TEST41: {
$ok = 0;
}
print ($ok ? "ok 41\n" : "not ok 41\n");
+
+
+# [perl #27206] Memory leak in continue loop
+# Ensure that the temporary object is freed each time round the loop,
+# rather then all 10 of them all being freed right at the end
+
+{
+ my $n=10; my $late_free = 0;
+ sub X::DESTROY { $late_free++ if $n < 0 };
+ {
+ ($n-- && bless {}, 'X') && redo;
+ }
+ print $late_free ? "not " : "", "ok 42 - redo memory leak\n";
+
+ $n = 10; $late_free = 0;
+ {
+ ($n-- && bless {}, 'X') && redo;
+ }
+ continue { }
+ print $late_free ? "not " : "", "ok 43 - redo with continue memory leak\n";
+}
+
+