From: Yuval Kogman Date: Fri, 15 Aug 2008 13:59:15 +0000 (+0300) Subject: a test for Paul Evan's qr leak X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=49c38585884a547ae094a6be3f8a37db3018e48d;p=p5sagit%2Fp5-mst-13.2.git a test for Paul Evan's qr leak --- 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" ); +