Don’t leak when compiling /(?[\d\d])/
authorFather Chrysostomos <sprout@cpan.org>
Thu, 6 Jun 2013 21:14:06 +0000 (14:14 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 7 Jun 2013 00:53:22 +0000 (17:53 -0700)
The ‘Operand with no preceding operator’ error was leaking the last
two operands.

regcomp.c
t/op/svleak.t

index fa0a840..173fd6c 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -11972,6 +11972,8 @@ S_handle_regex_sets(pTHX_ RExC_state_t *pRExC_state, SV** return_invlist, I32 *f
                     char current_operator;
 
                     if (IS_OPERAND(top)) {
+                        SvREFCNT_dec_NN(top);
+                        SvREFCNT_dec_NN(current);
                         vFAIL("Operand with no preceding operator");
                     }
                     current_operator = (char) SvUV(top);
index c8e0354..71bfbb7 100644 (file)
@@ -15,7 +15,7 @@ BEGIN {
 
 use Config;
 
-plan tests => 123;
+plan tests => 124;
 
 # 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
@@ -249,6 +249,7 @@ eleak(2,0,'no warnings; /(?[[a]^[b]])/');
 eleak(2,0,'no warnings; /(?[![a]])/');
 eleak(2,0,'no warnings; /(?[\p{Word}])/');
 eleak(2,0,'no warnings; /(?[[a]+)])/');
+eleak(2,0,'no warnings; /(?[\d\d)])/');
 
 # These can generate one ref count, but just  once.
 eleak(4,1,'chr(0x100) =~ /[[:punct:]]/');