aboutsummaryrefslogtreecommitdiff
path: root/source/i18n/ucol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/i18n/ucol.cpp')
-rw-r--r--source/i18n/ucol.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/source/i18n/ucol.cpp b/source/i18n/ucol.cpp
index b0d819f..e5ff44e 100644
--- a/source/i18n/ucol.cpp
+++ b/source/i18n/ucol.cpp
@@ -2259,6 +2259,9 @@ inline UChar getNextNormalizedChar(collIterate *data)
if (data->pos + 1 == data->endp) {
return *(data->pos ++);
}
+ if (data->pos >= data->endp) {
+ return (UChar) -1; // return U+FFFF (non-char) to indicate an error
+ }
}
else {
if (innormbuf) {
@@ -2821,7 +2824,13 @@ uint32_t ucol_prv_getSpecialCE(const UCollator *coll, UChar ch, uint32_t CE, col
}
}
} else if (U16_IS_LEAD(schar)) {
- miss = U16_GET_SUPPLEMENTARY(schar, getNextNormalizedChar(source));
+ UChar nextChar = getNextNormalizedChar(source);
+ const UChar* prevPos = source->pos;
+ if (U16_IS_TRAIL(nextChar)) {
+ miss = U16_GET_SUPPLEMENTARY(schar, nextChar);
+ } else if (prevPos < source->pos) {
+ goBackOne(source);
+ }
}
uint8_t sCC;