Stop /[:foo:]/ from leaking under fatal warnings
authorFather Chrysostomos <sprout@cpan.org>
Tue, 4 Dec 2012 19:18:36 +0000 (11:18 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 4 Dec 2012 22:33:31 +0000 (14:33 -0800)
This commit arranges for the regexp and one temporary sv in S_regclass
to be freed in case the ‘POSIX syntax [: :] belongs inside character
classes’ warning proves fatal.

regcomp.c
t/op/svleak.t

index f639116..e98bf34 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -11573,9 +11573,13 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
        while (isALNUM(*s))
            s++;
        if (*s && c == *s && s[1] == ']') {
+           SAVEFREESV(RExC_rx_sv);
+           SAVEFREESV(listsv);
            ckWARN3reg(s+2,
                       "POSIX syntax [%c %c] belongs inside character classes",
                       c, c);
+           ReREFCNT_inc(RExC_rx_sv);
+           SvREFCNT_inc_simple_void_NN(listsv);
        }
     }
 
index ad67259..129ad05 100644 (file)
@@ -101,8 +101,8 @@ eleak(2, 0, "$f 'closure';
 eleak(2, 0, "$all /(?{})?/ ", '(?{})? with fatal warnings');
 eleak(2, 0, "$all /(?{})+/ ", '(?{})+ with fatal warnings');
 eleak(2, 0, "$all /[\\i]/ ", 'invalid charclass escape with fatal warns');
-$::TODO = 'still leaks';
 eleak(2, 0, "$all /[:foo:]/ ", '/[:foo:]/ with fatal warnings');
+$::TODO = 'still leaks';
 eleak(2, 0, "$all /[a-\\d]/ ", '[a-\d] char class with fatal warnings');
 eleak(2, 0, "$all v111111111111111111111111111111111111111111111111",
      'vstring num overflow with fatal warnings');