DRASCULA: Fix some code analysis warnings (bug #3087830)

svn-id: r53473
This commit is contained in:
Eugene Sandulenko 2010-10-15 09:08:54 +00:00
parent b0923dfd76
commit 9b9e8f7d8d
3 changed files with 14 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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);