diff --git a/engines/drascula/resource.cpp b/engines/drascula/resource.cpp index 1226bc2e10e..57be51da430 100644 --- a/engines/drascula/resource.cpp +++ b/engines/drascula/resource.cpp @@ -92,13 +92,19 @@ void TextResourceParser::getLine(char *buf) { void TextResourceParser::parseInt(int &result) { char buf[256]; getLine(buf); - sscanf(buf, "%d", &result); + + if (!sscanf(buf, "%d", &result)) { + result = 0; + } } void TextResourceParser::parseString(char* result) { char buf[256]; getLine(buf); - sscanf(buf, "%s", result); + + if (!sscanf(buf, "%s", result)) { + *result = 0; + } } diff --git a/engines/drascula/rooms.cpp b/engines/drascula/rooms.cpp index 57bfad26afe..c6dd9f29dbe 100644 --- a/engines/drascula/rooms.cpp +++ b/engines/drascula/rooms.cpp @@ -1945,7 +1945,9 @@ bool DrasculaEngine::exitRoom(int doorNumber) { hare_se_ve = 1; clearRoom(); - sscanf(_targetSurface[doorNumber], "%d", &roomNum); + if (!sscanf(_targetSurface[doorNumber], "%d", &roomNum)) { + error("Malformed roomNum in targetSurface (%s)", _targetSurface[doorNumber]); + } curX = -1; enterRoom(roomNum); diff --git a/engines/drascula/saveload.cpp b/engines/drascula/saveload.cpp index 4aaec5ec0e9..4c288553a27 100644 --- a/engines/drascula/saveload.cpp +++ b/engines/drascula/saveload.cpp @@ -221,7 +221,9 @@ bool DrasculaEngine::loadGame(const char *gameName) { takeObject = sav->readSint32LE(); pickedObject = sav->readSint32LE(); loadedDifferentChapter = 0; - sscanf(currentData, "%d.ald", &roomNum); + if (!sscanf(currentData, "%d.ald", &roomNum)) { + error("Bad save format"); + } enterRoom(roomNum); selectVerb(kVerbNone);