summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-12-04 11:18:36 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-12-04 14:33:31 -0800
commitd15d727a14644c88dcdc421859433cb86111c0ea (patch)
treefc90a73328f044340a5166941c888da58684117a
parentf5eec17cdc8138641bd75afb9c79295f9bbecde3 (diff)
downloadperl-d15d727a14644c88dcdc421859433cb86111c0ea.tar.gz
Stop /[:foo:]/ from leaking under fatal warnings
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.
-rw-r--r--regcomp.c4
-rw-r--r--t/op/svleak.t2
2 files changed, 5 insertions, 1 deletions
diff --git a/regcomp.c b/regcomp.c
index f6391168f8..e98bf34c4b 100644
--- 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);
}
}
diff --git a/t/op/svleak.t b/t/op/svleak.t
index ad67259252..129ad0591a 100644
--- a/t/op/svleak.t
+++ b/t/op/svleak.t
@@ -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');