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
nirenjan 2026-03-08 19:56:33 -07:00
parent c63b924705
commit ef4cbee127
1 changed files with 3 additions and 1 deletions

View File

@ -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;
}