summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2011-05-13 08:35:23 -0600
committerKarl Williamson <public@khwilliamson.com>2011-05-18 10:52:39 -0600
commitf9126265bc03faa150614fa80fcd98e7056fb385 (patch)
tree299c0f2ef4f52fd749ddb312aeed7fac6e35f42f
parent17163f855fd26aa10245c144199729af4cc7ff81 (diff)
downloadperl-f9126265bc03faa150614fa80fcd98e7056fb385.tar.gz
Assertion fails in multi-char regex match
In '"s\N{U+DF}" =~ /\x{00DF}/i, the LHS folds to 'sss', the RHS to 'ss'. The bug occurs when the RHS tries to match the first two es's, but that splits the LHS \xDF character, which Perl doesn't know how to handle, and the assertion got triggered. (This is similar to [perl #72998].) The solution adopted here is to disallow a partial character match, as #72998 did as well.
-rw-r--r--regexec.c10
-rw-r--r--t/re/pat_advanced.t4
2 files changed, 10 insertions, 4 deletions
diff --git a/regexec.c b/regexec.c
index 391fc1604e..fd90ad7aa3 100644
--- a/regexec.c
+++ b/regexec.c
@@ -6726,9 +6726,12 @@ S_reginclass(pTHX_ const regexp * const prog, register const regnode * const n,
STRLEN len;
const char * const s = SvPV_const(sv, len);
- if (len <= total_foldlen && memEQ(s,
- (char*)folded,
- len))
+ if (len <= total_foldlen
+ && memEQ(s, (char*)folded, len)
+
+ /* If 0, means matched a partial char. See
+ * [perl #90536] */
+ && map_fold_len_back[len])
{
/* Advance the target string ptr to account for
@@ -6737,7 +6740,6 @@ S_reginclass(pTHX_ const regexp * const prog, register const regnode * const n,
* length. */
if (lenp) {
*lenp = map_fold_len_back[len];
- assert(*lenp != 0); /* Otherwise will loop */
}
match = TRUE;
break;
diff --git a/t/re/pat_advanced.t b/t/re/pat_advanced.t
index 6d7624d4fb..2a510d13aa 100644
--- a/t/re/pat_advanced.t
+++ b/t/re/pat_advanced.t
@@ -2108,6 +2108,10 @@ EOP
like("\x{00DF}", qr/[\x{1E9E}_]*/i, "\"\\x{00DF}\" =~ /[\\x{1E9E}_]*/i was looping");
}
+ { # Bug #90536, caused failed assertion
+ unlike("s\N{U+DF}", qr/^\x{00DF}/i, "\"s\\N{U+DF}\", qr/^\\x{00DF}/i");
+ }
+
# !!! NOTE that tests that aren't at all likely to crash perl should go
# a ways above, above these last ones.