mirror of https://github.com/nirenjan/libx52.git
fix: Handle malformed UTF-8 input in libx52util
The libx52util_convert_utf8_string function manually converts the UTF-8 string into the character map supported by the X52/X52Pro MFD. However, there was a bug when handling malformed UTF-8 input. If the state machine thinks it is at the start of a word and receives malformed UTF-8 input (between 0x80 and 0xC0), it will ignore the characters, but it will not reset the entry to the map_root location, thereby causing subsequent characters to be dropped. This change ensures that the entry is reset to map_root[*input] after skipping over an invalid UTF-8 sequence.pull/58/head
parent
c63b924705
commit
ef4cbee127
|
|
@ -75,10 +75,12 @@ int libx52util_convert_utf8_string(const uint8_t *input,
|
|||
while (*input >= 0x80 && *input < 0xC0) {
|
||||
input++; /* Skip invalid characters */
|
||||
}
|
||||
|
||||
/* New UTF-8 character, reset the entry pointer */
|
||||
entry = &map_root[*input];
|
||||
}
|
||||
}
|
||||
|
||||
*len = index;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue