Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

a test for Paul Evan's qr leak

  • Loading branch information...
commit 49c38585884a547ae094a6be3f8a37db3018e48d 1 parent e947c19
@nothingmuch nothingmuch authored
Showing with 34 additions and 0 deletions.
  1. +1 −0  MANIFEST
  2. +33 −0 t/op/qr_gc.t
View
1  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
View
33 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" );
+
Please sign in to comment.
Something went wrong with that request. Please try again.