| Index: source/i18n/ucol.cpp |
| =================================================================== |
| --- source/i18n/ucol.cpp (revision 292709) |
| +++ source/i18n/ucol.cpp (working copy) |
| @@ -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) { |
| @@ -2820,8 +2823,14 @@ uint32_t ucol_prv_getSpecialCE(const UCollator *coll, UChar ch, uint32_t CE, col |
| goBackOne(source); |
| } |
| } |
| - } else if (U16_IS_LEAD(schar)) { |
| - miss = U16_GET_SUPPLEMENTARY(schar, getNextNormalizedChar(source)); |
| + } else if (U16_IS_LEAD(schar) && source->pos + 1 < source->endp) { |
| + const UChar* prevPos = source->pos; |
| + UChar nextChar = getNextNormalizedChar(source); |
| + if (U16_IS_TRAIL(nextChar)) { |
| + miss = U16_GET_SUPPLEMENTARY(schar, nextChar); |
| + } else if (prevPos < source->pos) { |
| + goBackOne(source); |
| + } |
| } |
| |
| uint8_t sCC; |