Stop /[a-\d]/ from leaking under fatal warnings
authorFather Chrysostomos <sprout@cpan.org>
Tue, 4 Dec 2012 19:22:59 +0000 (11:22 -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 ‘False [] range’ warning proves fatal.

regcomp.c
t/op/svleak.t

index e98bf34..4736bbd 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -11893,9 +11893,13 @@ parseit:
                    const int w =
                        RExC_parse >= rangebegin ?
                        RExC_parse - rangebegin : 0;
+                   SAVEFREESV(RExC_rx_sv); /* in case of fatal warnings */
+                   SAVEFREESV(listsv);
                    ckWARN4reg(RExC_parse,
                               "False [] range \"%*.*s\"",
                               w, w, rangebegin);
+                   ReREFCNT_inc(RExC_rx_sv);
+                   SvREFCNT_inc_simple_void_NN(listsv);
                     cp_list = add_cp_to_invlist(cp_list, '-');
                     cp_list = add_cp_to_invlist(cp_list, prevvalue);
                }
index 129ad05..475baed 100644 (file)
@@ -102,8 +102,8 @@ 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');
 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');
+$::TODO = 'still leaks';
 eleak(2, 0, "$all v111111111111111111111111111111111111111111111111",
      'vstring num overflow with fatal warnings');
 undef $::TODO;