This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #129350] anchored/floating substrings must be utf8 if target is
authorHugo van der Sanden <hv@crypt.org>
Tue, 4 Oct 2016 13:40:11 +0000 (14:40 +0100)
committerHugo van der Sanden <hv@crypt.org>
Tue, 4 Oct 2016 14:02:36 +0000 (15:02 +0100)
If the target is utf8 and either the anchored or floating substrings
are not, we need to create utf8 copies to check against. The state
of the two substrings may not be the same, but we were only testing
whichever we planned to check first.

regexec.c
t/re/re_tests

index b86cb1b..e9e23f2 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -703,7 +703,8 @@ Perl_re_intuit_start(pTHX_
     reginfo->poscache_maxiter = 0;
 
     if (utf8_target) {
-       if (!prog->check_utf8 && prog->check_substr)
+        if ((!prog->anchored_utf8 && prog->anchored_substr)
+                || (!prog->float_utf8 && prog->float_substr))
            to_utf8_substr(prog);
        check = prog->check_utf8;
     } else {
index 35948b3..046628c 100644 (file)
@@ -1969,6 +1969,7 @@ ab(?#Comment){2}c abbc    y       $&      abbc
 aa$|a(?R)a|a   aaa     y       $&      aaa             # [perl 128420] recursive matches
 (?:\1|a)([bcd])\1(?:(?R)|e)\1  abbaccaddedcb   y       $&      abbaccaddedcb           # [perl 128420] recursive match with backreferences
 AB\s+\x{100}   AB \x{100}X     y       -       -
+\b\z0*\x{100}  .\x{100}        n       -       -       # [perl #129350] crashed in intuit_start
 
 # Keep these lines at the end of the file
 # vim: softtabstop=0 noexpandtab