Stop /[\i]/ from leaking under fatal warnings
authorFather Chrysostomos <sprout@cpan.org>
Mon, 3 Dec 2012 01:46:24 +0000 (17:46 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 3 Dec 2012 16:53:44 +0000 (08:53 -0800)
This commit arranges for the regexp and one temporary sv in S_regclass
to be freed in case the ‘Unrecognized escape \x in character class’
warning proves fatal.

regcomp.c
t/op/svleak.t

index 51b3e2a..a595a8c 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -11848,9 +11848,13 @@ parseit:
            default:
                /* Allow \_ to not give an error */
                if (!SIZE_ONLY && isALNUM(value) && value != '_') {
+                   SAVEFREESV(RExC_rx_sv);
+                   SAVEFREESV(listsv);
                    ckWARN2reg(RExC_parse,
                               "Unrecognized escape \\%c in character class passed through",
                               (int)value);
+                   ReREFCNT_inc(RExC_rx_sv);
+                   SvREFCNT_inc_simple_void_NN(listsv);
                }
                break;
            }
index f4abbdb..ad67259 100644 (file)
@@ -100,8 +100,8 @@ eleak(2, 0, "$f 'closure';
      'format closing over unavailable var with fatal warnings');
 eleak(2, 0, "$all /(?{})?/ ", '(?{})? with fatal warnings');
 eleak(2, 0, "$all /(?{})+/ ", '(?{})+ with fatal warnings');
-$::TODO = 'still leaks';
 eleak(2, 0, "$all /[\\i]/ ", 'invalid charclass escape with fatal warns');
+$::TODO = 'still leaks';
 eleak(2, 0, "$all /[:foo:]/ ", '/[:foo:]/ with fatal warnings');
 eleak(2, 0, "$all /[a-\\d]/ ", '[a-\d] char class with fatal warnings');
 eleak(2, 0, "$all v111111111111111111111111111111111111111111111111",