ILLUSIONS: Fix text handling crash on big-endian systems

The loop reversing the wide characters on big-endian systems would loop
until _tblPtr, which is way past all TalkEntry text parts, effectively
reversing the string multiple times at incorrect positions.  Thus, some
characters would remain in the incorrect endianness, and the game would
crash.

Trac tickets #11528 and #11236.
This commit is contained in:
Donovan Watteau 2021-07-03 00:17:21 +02:00 committed by Filippos Karapetis
parent f7d54f2341
commit a933dc768c

View File

@ -52,7 +52,7 @@ void TalkEntry::load(byte *dataStart, Common::SeekableReadStream &stream) {
_talkId, textOffs, tblOffs, voiceNameOffs);
#if defined(SCUMM_BIG_ENDIAN)
for (byte *ptr = (byte *)_text; ptr != _tblPtr; ptr += 2) {
for (byte *ptr = (byte *)_text; *ptr != 0; ptr += 2) {
WRITE_UINT16(ptr, SWAP_BYTES_16(READ_UINT16(ptr)));
}
#endif