This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Stop /(??{})/ from leaking temporary regexps
authorFather Chrysostomos <sprout@cpan.org>
Tue, 13 Nov 2012 20:44:16 +0000 (12:44 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 13 Nov 2012 22:54:21 +0000 (14:54 -0800)
regexec.c
t/op/svleak.t

index 4940641..72e2d7b 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -4962,6 +4962,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
                         * compiled */
                        S_regcp_restore(aTHX_ rex, runops_cp);
                    }
+                   SAVEFREESV(re_sv);
                    re = ReANY(re_sv);
                }
                 RXp_MATCH_COPIED_off(re);
index 8416656..b89d6d0 100644 (file)
@@ -15,7 +15,7 @@ BEGIN {
 
 use Config;
 
-plan tests => 65;
+plan tests => 66;
 
 # run some code N times. If the number of SVs at the end of loop N is
 # greater than (N-1)*delta at the end of loop 1, we've got a leak
@@ -182,6 +182,7 @@ eleak(2,0,'/[\xdf]/i');
 eleak(2,0,'s![^/]!!');
 eleak(2,0,'/[pp]/');
 eleak(2,0,'/[[:ascii:]]/');
+leak(2,0,sub { /(??{})/ }, '/(??{})/');
 
 leak(2,0,sub { !$^V }, '[perl #109762] version object in boolean context');