From 49c38585884a547ae094a6be3f8a37db3018e48d Mon Sep 17 00:00:00 2001 From: Yuval Kogman Date: Fri, 15 Aug 2008 16:59:15 +0300 Subject: [PATCH] a test for Paul Evan's qr leak --- MANIFEST | 1 + t/op/qr_gc.t | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 t/op/qr_gc.t diff --git a/MANIFEST b/MANIFEST index e97e615..9df546d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -4083,6 +4083,7 @@ t/op/pwent.t See if getpw*() functions work t/op/qq.t See if qq works t/op/qrstack.t See if qr expands the stack properly t/op/qr.t See if qr works +t/op/qr_gc.t See if qr doesn't leak t/op/quotemeta.t See if quotemeta works t/op/rand.t See if rand works t/op/range.t See if .. works diff --git a/t/op/qr_gc.t b/t/op/qr_gc.t new file mode 100644 index 0000000..7de3f84 --- /dev/null +++ b/t/op/qr_gc.t @@ -0,0 +1,33 @@ +#!./perl -w + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; + require './test.pl'; +} + +plan tests => 2; + +$TODO = "leaking since 32751"; + +my $destroyed; +{ + no warnings 'redefine'; + sub Regexp::DESTROY { $destroyed++ } +} + +{ + my $rx = qr//; +} + +is( $destroyed, 1, "destroyed regexp" ); + +undef $destroyed; + +{ + my $var = bless {}, "Foo"; + my $rx = qr/(?{ $var })/; +} + +is( $destroyed, 1, "destroyed regexp with closure capture" ); + -- 1.8.3.1