aboutsummaryrefslogtreecommitdiff
path: root/patches/col.patch
blob: aa117fe5a836ac12ac88a89dcbc8bbe268eee715 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Index: source/i18n/ucol.cpp
===================================================================
--- source/i18n/ucol.cpp	(revision 292709)
+++ source/i18n/ucol.cpp	(working copy)
@@ -2259,6 +2259,9 @@
         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 @@
                                 }
                             }
                         } 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;