mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-27 21:54:15 +00:00
STARTREK: Ensure that we're not reading past the end of RDF files
This commit is contained in:
parent
2761107ae3
commit
c6d3f1df65
@ -122,25 +122,32 @@ Room::~Room() {
|
||||
void Room::loadRoomMessages() {
|
||||
// TODO: There are some more messages which are not stored in that offset
|
||||
uint16 messagesOffset = readRdfWord(32);
|
||||
uint16 offset = messagesOffset;
|
||||
const char *text = (const char *)_rdfData + messagesOffset;
|
||||
const char roomIndexChar = '0' + _vm->_roomIndex;
|
||||
|
||||
do {
|
||||
while (text[0] != '#' || (text[1] != _vm->_missionName[0] && text[4] != roomIndexChar))
|
||||
while ((text[0] != '#' || (text[1] != _vm->_missionName[0] && text[4] != roomIndexChar)) && offset < _rdfSize) {
|
||||
text++;
|
||||
offset++;
|
||||
}
|
||||
|
||||
if (text[5] == '\\')
|
||||
loadRoomMessage(text);
|
||||
|
||||
while (*text != '\0')
|
||||
while (*text != '\0' && offset < _rdfSize) {
|
||||
text++;
|
||||
offset++;
|
||||
}
|
||||
|
||||
// Peek the next byte, in case there's a filler text
|
||||
if (Common::isAlpha(*(text + 1))) {
|
||||
while (*text != '\0')
|
||||
while (*text != '\0' && offset < _rdfSize) {
|
||||
text++;
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
} while (*(text + 1) == '#');
|
||||
} while (*(text + 1) == '#' && offset < _rdfSize);
|
||||
}
|
||||
|
||||
void Room::loadRoomMessage(const char *text) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user