blob: 8a743d0b3cd9cd1d33f6cfdf18e6d46fc73721d6 [file] [log] [blame]
Change 579272908 by alexsav@alexsav:fig-export-clean-1452-change-1:1454:citc on 2023/11/03 12:42:34
Adds check for u16_u8 xFF
PRESUBMIT=passed
BUG=308240685
FIXED=308240685
R=mghiware
APPROVED=mghiware
REQUIRED_REVIEW=1
DELTA=8 (7 added, 0 deleted, 1 changed)
DELTA_BY_EXTENSION=cxx=8
OCL=578306755
FIG_CHANGESET=ea4fd90ff399df9c012782dcd2c45439c6e9fcaf
FIG_WORKSPACE=alexsav/1452:clean
Affected files ...
... //depot//src/hunspell/csutil.cxx#4 edit
==== //depot//src/hunspell/csutil.cxx#3 - /google/src/files/579272908/depot//src/hunspell/csutil.cxx ====
--- /google/src/files/537916729/depot//src/hunspell/csutil.cxx 2023-06-05 13:32:42.000000000 -0400
+++ /google/src/files/579272908/depot//src/hunspell/csutil.cxx 2023-11-03 15:42:34.000000000 -0400
@@ -48,7 +48,14 @@
while ((u2 < u2_max) && (u8 < u8_max)) {
if (u2->h) { // > 0xFF
// XXX 4-byte haven't implemented yet.
- if (u2->h >= 0x08) { // >= 0x800 (3-byte UTF-8 character)
+ if (u2->h == 0xFF) {
+ // Error case. Handling this with the below else case will insert
+ // \U0000FFFD, shifting the string and pushing it into other
+ // memory locations, which might be later read as garbage and
+ // cause memory errors.
+ *u8 = 0xFF;
+ u8++;
+ } else if (u2->h >= 0x08) { // >= 0x800 (3-byte UTF-8 character)
*u8 = 0xe0 + (u2->h >> 4);
u8++;
if (u8 < u8_max) {