diff options
-rw-r--r-- | engines/m4/console.cpp | 6 | ||||
-rw-r--r-- | engines/m4/converse.cpp | 5 | ||||
-rw-r--r-- | engines/m4/dialogs.cpp | 2 | ||||
-rw-r--r-- | engines/m4/mads_logic.cpp | 4 |
4 files changed, 12 insertions, 5 deletions
diff --git a/engines/m4/console.cpp b/engines/m4/console.cpp index 71c70e3e1b..3e7f9624cf 100644 --- a/engines/m4/console.cpp +++ b/engines/m4/console.cpp @@ -61,8 +61,10 @@ static int strToInt(const char *s) { return atoi(s); // Hexadecimal string - uint tmp; - sscanf(s, "%xh", &tmp); + uint tmp = 0; + int read = sscanf(s, "%xh", &tmp); + if (read < 1) + error("strToInt failed on string \"%s\"", s); return (int)tmp; } diff --git a/engines/m4/converse.cpp b/engines/m4/converse.cpp index af26a86313..6a11c328ff 100644 --- a/engines/m4/converse.cpp +++ b/engines/m4/converse.cpp @@ -541,6 +541,9 @@ void Converse::loadConversation(const char *convName) { if (debugFlag) printf("Reply data offset: %i\n", data); } + if (!curEntry) + error("Converse::loadConversation(): curEntry is NULL while adding a reply"); + curEntry->entries.push_back(replyEntry); setEntryInfo(replyEntry->offset, replyEntry->entryType, curNode, _convNodes[curNode]->entries.size() - 1); @@ -572,6 +575,8 @@ void Converse::loadConversation(const char *convName) { } else if (replyEntry != NULL && replyEntry->entryType == kWeightedReply) { parentEntry = replyEntry->entries[currentWeightedEntry]; currentWeightedEntry++; + } else { + error("Converse::loadConversation(): Unexpected reply entry while processing TEXT/MESG chunk"); } size = convS->readUint32LE(); diff --git a/engines/m4/dialogs.cpp b/engines/m4/dialogs.cpp index a7104537f5..101f21f48c 100644 --- a/engines/m4/dialogs.cpp +++ b/engines/m4/dialogs.cpp @@ -297,7 +297,7 @@ Dialog::Dialog(MadsM4Engine *vm, const char *msgData, const char *title): View(v char *lineP = &dialogLine[0]; char *cmdP = NULL; - while (*(srcP - 1) != '\0') { + while (srcP && *(srcP - 1) != '\0') { if ((*srcP == '\n') || (*srcP == '\0')) { // Line completed *lineP = '\0'; diff --git a/engines/m4/mads_logic.cpp b/engines/m4/mads_logic.cpp index cebe2215ca..7eb8f900a8 100644 --- a/engines/m4/mads_logic.cpp +++ b/engines/m4/mads_logic.cpp @@ -658,12 +658,12 @@ void MadsSceneLogic::execute(uint32 subOffset) { case OP_NOT: // logical nots top item on stack param = stack.pop().get(); - stack.push(ScriptVar((uint32)!param & 0xffff)); + stack.push(ScriptVar((uint32)!(param & 0xffff))); break; case OP_COMP: // complements top item on stack param = stack.pop().get(); - stack.push(ScriptVar(~param & 0xffff)); + stack.push(ScriptVar(~(param & 0xffff))); break; case OP_NEG: // negates top item on stack |