DREAMWEB: Avoid out of bound read with empty strings in printDirect

In the French version of the game, right at the start (in the first
scene) there was a crash due to an out of bound read with a string
of length 1 (empty, with only the '\0' character). This commit
moves reading the next character to after checking that that the
character is not '\0' to avoid this out of bound read.
This fixes bug #15546.
This commit is contained in:
Thierry Crozat authored and Filippos Karapetis committed 2024-12-02 02:37:11 +02:00
1 parent 6f4ffe3b06
commit 826660b92a
1 file changed
+2 -2
+2 -2
View File
@@ -138,11 +138,11 @@ uint8 DreamWebEngine::printDirect(const uint8** string, uint16 x, uint16 *y, uin
uint16 i = offset;
do {
uint8 c = (*string)[0];
uint8 nextChar = (*string)[1];
++(*string);
if ((c == 0) || (c == ':')) {
return c;
}
uint8 nextChar = (*string)[1];
++(*string);
c = modifyChar(c);
uint8 width, height;
printChar(charSet, &i, *y, c, nextChar, &width, &height);