aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2010-10-15 15:05:23 +0000
committerFilippos Karapetis2010-10-15 15:05:23 +0000
commitc2e08538ee87e156720e6adc5da0bdb090df6a39 (patch)
tree1a8054a94144ae7abae1b6f9ddb3bae1bc956979
parentabcceb8a4eb96fd864cb38bec401974a44e33661 (diff)
downloadscummvm-rg350-c2e08538ee87e156720e6adc5da0bdb090df6a39.tar.gz
scummvm-rg350-c2e08538ee87e156720e6adc5da0bdb090df6a39.tar.bz2
scummvm-rg350-c2e08538ee87e156720e6adc5da0bdb090df6a39.zip
M4: Fixed code analysis warnings - bug #3087845
svn-id: r53500
-rw-r--r--engines/m4/console.cpp6
-rw-r--r--engines/m4/converse.cpp5
-rw-r--r--engines/m4/dialogs.cpp2
-rw-r--r--engines/m4/mads_logic.cpp4
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