diff options
-rw-r--r-- | engines/engine.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/scumm.cpp | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/engines/engine.cpp b/engines/engine.cpp index 2c9835acc5..a663b1e139 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -253,6 +253,8 @@ bool Engine::shouldPerformAutoSave(int lastSaveTime) { void Engine::errorString(const char *buf1, char *buf2, int size) { strncpy(buf2, buf1, size); + if (size > 0) + buf2[size-1] = '\0'; } void Engine::pauseEngine(bool pause) { diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 93605fa29b..ddae3141c4 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -2343,7 +2343,9 @@ void ScummEngine::errorString(const char *buf1, char *buf2, int buf2Size) { snprintf(buf2, buf2Size, "(%d:%d:0x%lX): %s", _roomResource, vm.slot[_currentScript].number, (long)(_scriptPointer - _scriptOrgPointer), buf1); } else { - strcpy(buf2, buf1); + strncpy(buf2, buf1, buf2Size); + if (buf2Size > 0) + buf2[buf2Size-1] = '\0'; } } |