In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/057d0762a3f1ec936b6fc44f6c6d9daa99a2f751?hp=b15b9c2a4267eed1abe5a08e57b250f7fab2e9f9>
- Log ----------------------------------------------------------------- commit 057d0762a3f1ec936b6fc44f6c6d9daa99a2f751 Author: Father Chrysostomos <[email protected]> Date: Tue Dec 4 11:22:59 2012 -0800 Stop /[a-\d]/ from leaking under fatal warnings This commit arranges for the regexp and one temporary sv in S_regclass to be freed in case the âFalse [] rangeâ warning proves fatal. M regcomp.c M t/op/svleak.t commit d15d727a14644c88dcdc421859433cb86111c0ea Author: Father Chrysostomos <[email protected]> Date: Tue Dec 4 11:18:36 2012 -0800 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. M regcomp.c M t/op/svleak.t commit f5eec17cdc8138641bd75afb9c79295f9bbecde3 Author: Father Chrysostomos <[email protected]> Date: Tue Dec 4 11:04:24 2012 -0800 [perl #115818] Donât croak for /[.zog.]/ /[.zog.]/ produces a warning, because the POSIX syntax is not used correctly. It must be /[[.zog.]]/. /[[.zog.]]/ croaks, because that POSIX syntax has not been imple- mented yet. There is currently a croak for the former, too, even though it is the latter syntax that is forbidden. There is no reason to forbid the former. The reason for warning is that /[.zog.]/ is a regular character class (equivalent to [.zog]), so it might not do what the programmer intended. If that is why we warn, it doesnât make sense to croak. After all, perl is only guessing that the programmer *might* have made a mistake. This makes /[.foo.]/ similar to /[:foo:]/, which warns and then acts like /[:fo]/. M regcomp.c M t/lib/warnings/regcomp ----------------------------------------------------------------------- Summary of changes: regcomp.c | 18 ++++++++---------- t/lib/warnings/regcomp | 1 - t/op/svleak.t | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/regcomp.c b/regcomp.c index a595a8c..4736bbd 100644 --- a/regcomp.c +++ b/regcomp.c @@ -11573,19 +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); - - /* [[=foo=]] and [[.foo.]] are still future. */ - if (POSIXCC_NOTYET(c)) { - /* adjust RExC_parse so the error shows after - the class closes */ - while (UCHARAT(RExC_parse) && UCHARAT(RExC_parse++) != ']') - NOOP; - SvREFCNT_dec(listsv); - vFAIL3("POSIX syntax [%c %c] is reserved for future extensions", c, c); - } + ReREFCNT_inc(RExC_rx_sv); + SvREFCNT_inc_simple_void_NN(listsv); } } @@ -11899,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/lib/warnings/regcomp b/t/lib/warnings/regcomp index 84d46fc..cb0c703 100644 --- a/t/lib/warnings/regcomp +++ b/t/lib/warnings/regcomp @@ -98,7 +98,6 @@ no warnings 'regexp' ; /[.zog.]/; EXPECT POSIX syntax [. .] belongs inside character classes in regex; marked by <-- HERE in m/[.zog.] <-- HERE / at - line 5. -POSIX syntax [. .] is reserved for future extensions in regex; marked by <-- HERE in m/[.zog.] <-- HERE / at - line 5. ######## # regcomp.c [S_regclass] $_ = ""; diff --git a/t/op/svleak.t b/t/op/svleak.t index ad67259..475baed 100644 --- a/t/op/svleak.t +++ b/t/op/svleak.t @@ -101,9 +101,9 @@ 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'); 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; -- Perl5 Master Repository
