In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/33bc5d3d6ec3a139b32d094c90b2f78d7a3a2399?hp=1e0a64115c2048e2aa95c55b284bec003e28b695>
- Log ----------------------------------------------------------------- commit 33bc5d3d6ec3a139b32d094c90b2f78d7a3a2399 Author: Karl Williamson <[email protected]> Date: Thu Jul 21 09:58:21 2016 -0600 PATCH: [perl 128686] regex compiler crashes This was due to freeing a scalar before its final use ----------------------------------------------------------------------- Summary of changes: regcomp.c | 20 ++++++++------------ t/re/pat.t | 12 +++++++++++- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/regcomp.c b/regcomp.c index 7f6d5ee..bba5a2b 100644 --- a/regcomp.c +++ b/regcomp.c @@ -17475,22 +17475,15 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth, &nonascii_but_latin1_properties); /* And add them to the final list of such characters. */ - if (has_upper_latin1_only_utf8_matches) { - _invlist_union(has_upper_latin1_only_utf8_matches, - nonascii_but_latin1_properties, - &has_upper_latin1_only_utf8_matches); - SvREFCNT_dec_NN(nonascii_but_latin1_properties); - } - else { - has_upper_latin1_only_utf8_matches - = nonascii_but_latin1_properties; - } + _invlist_union(has_upper_latin1_only_utf8_matches, + nonascii_but_latin1_properties, + &has_upper_latin1_only_utf8_matches); /* Remove them from what now becomes the unconditional list */ _invlist_subtract(posixes, nonascii_but_latin1_properties, &posixes); - /* And the remainder are the unconditional ones */ + /* And add those unconditional ones to the final list */ if (cp_list) { _invlist_union(cp_list, posixes, &cp_list); SvREFCNT_dec_NN(posixes); @@ -17500,8 +17493,11 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth, cp_list = posixes; } + SvREFCNT_dec(nonascii_but_latin1_properties); + /* Get rid of any characters that we now know are matched - * unconditionally from the conditional list */ + * unconditionally from the conditional list, which may make + * that list empty */ _invlist_subtract(has_upper_latin1_only_utf8_matches, cp_list, &has_upper_latin1_only_utf8_matches); diff --git a/t/re/pat.t b/t/re/pat.t index f6bd04a..98cdbe3 100644 --- a/t/re/pat.t +++ b/t/re/pat.t @@ -23,7 +23,7 @@ BEGIN { skip_all_without_unicode_tables(); } -plan tests => 796; # Update this when adding/deleting tests. +plan tests => 798; # Update this when adding/deleting tests. run_tests() unless caller; @@ -1781,6 +1781,16 @@ EOP /.*a.*b.*c.*[de]/; ',"Timeout",{},"Test Perl 73464") } + + { # [perl #128686], crashed the the interpreter + my $AE = chr utf8::unicode_to_native(0xC6); + my $ae = chr utf8::unicode_to_native(0xE6); + my $re = qr/[$ae\s]/i; + ok($AE !~ $re, '/[\xE6\s]/i doesn\'t match \xC6 when not in UTF-8'); + utf8::upgrade $AE; + ok($AE =~ $re, '/[\xE6\s]/i matches \xC6 when in UTF-8'); + } + } # End of sub run_tests 1; -- Perl5 Master Repository
