mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
ICU-8823 merge r30688 from ICU-8824 - UMR in rematch
X-SVN-Rev: 30706
This commit is contained in:
parent
5215940919
commit
3df82033a7
1 changed files with 22 additions and 14 deletions
|
@ -5639,6 +5639,7 @@ GC_Done:
|
|||
const UChar *foldChars = NULL;
|
||||
int32_t foldOffset, foldLength;
|
||||
UChar32 c;
|
||||
UBool c_is_valid = FALSE;
|
||||
|
||||
#ifdef REGEX_SMART_BACKTRACKING
|
||||
int32_t originalInputIdx = fp->fInputIdx;
|
||||
|
@ -5648,23 +5649,31 @@ GC_Done:
|
|||
foldOffset = foldLength = 0;
|
||||
|
||||
while (patternChars < patternEnd && success) {
|
||||
if(foldOffset < foldLength) {
|
||||
U16_NEXT_UNSAFE(foldChars, foldOffset, c);
|
||||
} else {
|
||||
U16_NEXT(inputBuf, fp->fInputIdx, fActiveLimit, c);
|
||||
foldLength = ucase_toFullFolding(csp, c, &foldChars, U_FOLD_CASE_DEFAULT);
|
||||
if(foldLength >= 0) {
|
||||
if(foldLength <= UCASE_MAX_STRING_LENGTH) { // !!!: Does not correctly handle chars that fold to 0-length strings
|
||||
foldOffset = 0;
|
||||
U16_NEXT_UNSAFE(foldChars, foldOffset, c);
|
||||
} else {
|
||||
c = foldLength;
|
||||
foldLength = foldOffset; // to avoid reading chars from the folding buffer
|
||||
if (fp->fInputIdx < fActiveLimit) { // don't read past end of string
|
||||
if(foldOffset < foldLength) {
|
||||
U16_NEXT_UNSAFE(foldChars, foldOffset, c);
|
||||
c_is_valid = TRUE;
|
||||
} else {
|
||||
// test pre-condition of U16_NEXT: i < length
|
||||
U_ASSERT(fp->fInputIdx < fActiveLimit);
|
||||
U16_NEXT(inputBuf, fp->fInputIdx, fActiveLimit, c);
|
||||
c_is_valid = TRUE;
|
||||
foldLength = ucase_toFullFolding(csp, c, &foldChars, U_FOLD_CASE_DEFAULT);
|
||||
if(foldLength >= 0) {
|
||||
if(foldLength <= UCASE_MAX_STRING_LENGTH) { // !!!: Does not correctly handle chars that fold to 0-length strings
|
||||
foldOffset = 0;
|
||||
U16_NEXT_UNSAFE(foldChars, foldOffset, c);
|
||||
} else {
|
||||
c = foldLength;
|
||||
foldLength = foldOffset; // to avoid reading chars from the folding buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
c_is_valid = FALSE;
|
||||
}
|
||||
|
||||
if (fp->fInputIdx <= fActiveLimit) {
|
||||
if (fp->fInputIdx <= fActiveLimit && c_is_valid) {
|
||||
if (U_IS_BMP(c)) {
|
||||
success = (*patternChars == c);
|
||||
patternChars += 1;
|
||||
|
@ -6111,4 +6120,3 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RegexMatcher)
|
|||
U_NAMESPACE_END
|
||||
|
||||
#endif // !UCONFIG_NO_REGULAR_EXPRESSIONS
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue