GRAPHICS: MACGUI: Made readHex() more robust

This fixes crashes in Markdown with malformed translations
This commit is contained in:
Eugene Sandulenko 2024-01-05 01:04:08 +01:00
parent f7f152ca1d
commit 7361c0f2fa
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -1504,13 +1504,13 @@ const Common::U32String::value_type *readHex(uint16 *res, const Common::U32Strin
*res = 0;
for (int i = 0; i < len; i++) {
char b = (char)*s++;
char b = tolower((char)*s++);
*res <<= 4;
if (tolower(b) >= 'a')
*res |= tolower(b) - 'a' + 10;
else
*res |= tolower(b) - '0';
if (b >= 'a' && b <= 'f')
*res |= b - 'a' + 10;
else if (b >= '0' && b <= '9')
*res |= b - '0';
}
return s;