aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEric Fry2018-04-30 18:25:49 +1000
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit39798c63d1d6a7153527a726acfa3c1cf837760f (patch)
tree0e768d7cbafa98c973cd4b014e9c05ed779c33ca /engines
parent9be0a7b08589163d9c0ff151d3fcd15e0e766bba (diff)
downloadscummvm-rg350-39798c63d1d6a7153527a726acfa3c1cf837760f.tar.gz
scummvm-rg350-39798c63d1d6a7153527a726acfa3c1cf837760f.tar.bz2
scummvm-rg350-39798c63d1d6a7153527a726acfa3c1cf837760f.zip
ILLUSIONS: Fix static buffer overrun in debug log function.
This was causing the game to crash when loading the main scumm menu. It was corrupting another static string in the about dialog.
Diffstat (limited to 'engines')
-rw-r--r--engines/illusions/illusions.cpp13
-rw-r--r--engines/illusions/illusions.h2
-rw-r--r--engines/illusions/resources/scriptresource.cpp11
-rw-r--r--engines/illusions/threads/talkthread.cpp11
-rw-r--r--engines/illusions/threads/talkthread_duckman.cpp11
5 files changed, 15 insertions, 33 deletions
diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp
index 9224ba9139..7b2f5f9b04 100644
--- a/engines/illusions/illusions.cpp
+++ b/engines/illusions/illusions.cpp
@@ -61,6 +61,19 @@
namespace Illusions {
+char *debugW2I(byte *wstr) {
+ static char buf[65];
+ char *p = buf;
+ int i = 0;
+ while (*wstr != 0 && i < sizeof(buf) - 1) {
+ *p++ = *wstr;
+ wstr += 2;
+ i++;
+ }
+ *p = 0;
+ return buf;
+}
+
IllusionsEngine::IllusionsEngine(OSystem *syst, const IllusionsGameDescription *gd) :
Engine(syst), _gameDescription(gd) {
diff --git a/engines/illusions/illusions.h b/engines/illusions/illusions.h
index ac6ff3b82a..4b3efa2294 100644
--- a/engines/illusions/illusions.h
+++ b/engines/illusions/illusions.h
@@ -44,6 +44,8 @@ struct ADGameDescription;
namespace Illusions {
+char *debugW2I(byte *wstr);
+
#define ILLUSIONS_SAVEGAME_VERSION 0
class ResourceSystem;
diff --git a/engines/illusions/resources/scriptresource.cpp b/engines/illusions/resources/scriptresource.cpp
index 5472d28658..53de6b4d2c 100644
--- a/engines/illusions/resources/scriptresource.cpp
+++ b/engines/illusions/resources/scriptresource.cpp
@@ -217,17 +217,6 @@ SceneInfo::~SceneInfo() {
delete[] _resources;
}
-char *debugW2I(byte *wstr) {
- static char buf[65];
- char *p = buf;
- while (*wstr != 0) {
- *p++ = *wstr;
- wstr += 2;
- }
- *p = 0;
- return buf;
-}
-
void SceneInfo::load(byte *dataStart, Common::SeekableReadStream &stream) {
_id = stream.readUint16LE();
_unk = stream.readUint16LE();
diff --git a/engines/illusions/threads/talkthread.cpp b/engines/illusions/threads/talkthread.cpp
index f8b4c15bf4..5b54abc583 100644
--- a/engines/illusions/threads/talkthread.cpp
+++ b/engines/illusions/threads/talkthread.cpp
@@ -285,17 +285,6 @@ void TalkThread::refreshText() {
_textEndTime = _textStartTime + _textDuration;
}
-static char *debugW2I(byte *wstr) {
- static char buf[65];
- char *p = buf;
- while (*wstr != 0) {
- *p++ = *wstr;
- wstr += 2;
- }
- *p = 0;
- return buf;
-}
-
int TalkThread::insertText() {
debug("%08X %08X [%s]", _threadId, _talkId, debugW2I(_currEntryText));
WidthHeight dimensions;
diff --git a/engines/illusions/threads/talkthread_duckman.cpp b/engines/illusions/threads/talkthread_duckman.cpp
index 07fe1bb56a..2d6c455b1c 100644
--- a/engines/illusions/threads/talkthread_duckman.cpp
+++ b/engines/illusions/threads/talkthread_duckman.cpp
@@ -293,17 +293,6 @@ void TalkThread_Duckman::refreshText() {
_textEndTime = _textStartTime + _textDuration;
}
-static char *debugW2I(byte *wstr) {
- static char buf[65];
- char *p = buf;
- while (*wstr != 0) {
- *p++ = *wstr;
- wstr += 2;
- }
- *p = 0;
- return buf;
-}
-
int TalkThread_Duckman::insertText() {
debug(0, "%08X %08X [%s]", _threadId, _talkId, debugW2I(_currEntryText));
WidthHeight dimensions;