From 057d0762a3f1ec936b6fc44f6c6d9daa99a2f751 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Tue, 4 Dec 2012 11:22:59 -0800 Subject: [PATCH] Stop /[a-\d]/ from leaking under fatal warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 4 ++++ t/op/svleak.t | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/regcomp.c b/regcomp.c index e98bf34..4736bbd 100644 --- 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); } diff --git a/t/op/svleak.t b/t/op/svleak.t index 129ad05..475baed 100644 --- a/t/op/svleak.t +++ b/t/op/svleak.t @@ -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; -- 2.7.4