diff options
-rw-r--r-- | engines/agi/predictive.cpp | 3 | ||||
-rw-r--r-- | engines/scumm/detection.cpp | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/engines/agi/predictive.cpp b/engines/agi/predictive.cpp index a3725249e6..c4b6649563 100644 --- a/engines/agi/predictive.cpp +++ b/engines/agi/predictive.cpp @@ -73,6 +73,7 @@ void bringWordtoTop(char *str, int wordnum) { if (!str) return; strncpy(buf, str, MAXLINELEN); + buf[MAXLINELEN - 1] = 0; char *word = strtok(buf, " "); if (!word) { debug("Invalid dictionary line"); @@ -415,6 +416,7 @@ bool AgiEngine::predictiveDialog() { _wordNumber = (_wordNumber + 1) % numMatchingWords; char tmp[MAXLINELEN]; strncpy(tmp, _predictiveDictActLine, MAXLINELEN); + tmp[MAXLINELEN - 1] = 0; char *tok = strtok(tmp, " "); for (uint8 i = 0; i <= _wordNumber; i++) tok = strtok(NULL, " "); @@ -590,6 +592,7 @@ bool AgiEngine::matchWord() { _predictiveDictActLine = _predictiveDictLine[line]; char tmp[MAXLINELEN]; strncpy(tmp, _predictiveDictActLine, MAXLINELEN); + tmp[MAXLINELEN - 1] = 0; char *tok = strtok(tmp, " "); tok = strtok(NULL, " "); _currentWord = String(tok, _currentCode.size()); diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index bd9fc06655..e1a2a4866a 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -180,6 +180,7 @@ static Common::String generateFilenameForDetection(const char *pattern, Filename error("generateFilenameForDetection: Unsupported genMethod"); } + buf[sizeof(buf) - 1] = 0; return buf; } |