diff options
author | Littleboy | 2011-06-23 05:42:48 -0400 |
---|---|---|
committer | Littleboy | 2011-06-23 08:52:52 -0400 |
commit | b694a78f62a02253bca2a5611314599ae7fce725 (patch) | |
tree | 115573b00e3b025ed334f9eadeadfb6161286089 /engines/scumm | |
parent | 7a96e0bfb67e9b5b8c0aa9bdae8415fb98214c3f (diff) | |
download | scummvm-rg350-b694a78f62a02253bca2a5611314599ae7fce725.tar.gz scummvm-rg350-b694a78f62a02253bca2a5611314599ae7fce725.tar.bz2 scummvm-rg350-b694a78f62a02253bca2a5611314599ae7fce725.zip |
ANALYSIS: Add static casts to is* functions
This fixes a potential problem with passing char values that would be sign-extended and yield unexpected results.
See http://msdn.microsoft.com/en-us/library/ms245348.aspx
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/smush/smush_player.cpp | 4 | ||||
-rw-r--r-- | engines/scumm/string.cpp | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp index 66502572de..2f4e86bf61 100644 --- a/engines/scumm/smush/smush_player.cpp +++ b/engines/scumm/smush/smush_player.cpp @@ -90,13 +90,13 @@ public: assert(def_end != NULL); char *id_end = def_end; - while (id_end >= def_start && !isdigit(*(id_end-1))) { + while (id_end >= def_start && !isdigit(static_cast<unsigned char>(*(id_end-1)))) { id_end--; } assert(id_end > def_start); char *id_start = id_end; - while (isdigit(*(id_start - 1))) { + while (isdigit(static_cast<unsigned char>(*(id_start - 1)))) { id_start--; } diff --git a/engines/scumm/string.cpp b/engines/scumm/string.cpp index 4b3207c6bf..2d2209c155 100644 --- a/engines/scumm/string.cpp +++ b/engines/scumm/string.cpp @@ -1383,10 +1383,10 @@ void ScummEngine_v7::loadLanguageBundle() { } else if (*ptr == '#') { // Number of subtags following a given basetag. We don't need that // information so we just skip it - } else if (isdigit(*ptr)) { + } else if (isdigit(static_cast<unsigned char>(*ptr))) { int idx = 0; // A number (up to three digits)... - while (isdigit(*ptr)) { + while (isdigit(static_cast<unsigned char>(*ptr))) { idx = idx * 10 + (*ptr - '0'); ptr++; } @@ -1424,12 +1424,12 @@ void ScummEngine_v7::loadLanguageBundle() { for (i = 0; i < _languageIndexSize; i++) { // First 8 chars in the line give the string ID / 'tag' int j; - for (j = 0; j < 8 && !isspace(*ptr); j++, ptr++) + for (j = 0; j < 8 && !isspace(static_cast<unsigned char>(*ptr)); j++, ptr++) _languageIndex[i].tag[j] = toupper(*ptr); _languageIndex[i].tag[j] = 0; // After that follows a single space which we skip - assert(isspace(*ptr)); + assert(isspace(static_cast<unsigned char>(*ptr))); ptr++; // Then comes the translated string: we record an offset to that. |