aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/alan2/alan2.cpp
diff options
context:
space:
mode:
authorLe Philousophe2019-07-07 09:52:54 +0200
committerPaul Gilbert2019-07-07 09:26:52 -0700
commit1c87f428d00d795297bdf8d4ef68eabf68a3e571 (patch)
treef46e5ae22d7655587a7bf5ab455bfbe2b316a3fa /engines/glk/alan2/alan2.cpp
parentda7ed2d90614afa6a7e18bad8586b35d4a217d3e (diff)
downloadscummvm-rg350-1c87f428d00d795297bdf8d4ef68eabf68a3e571.tar.gz
scummvm-rg350-1c87f428d00d795297bdf8d4ef68eabf68a3e571.tar.bz2
scummvm-rg350-1c87f428d00d795297bdf8d4ef68eabf68a3e571.zip
GLK: Fix off-by-one memory read
The for loop shouldn't check previous entity on the first iteration
Diffstat (limited to 'engines/glk/alan2/alan2.cpp')
-rw-r--r--engines/glk/alan2/alan2.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/engines/glk/alan2/alan2.cpp b/engines/glk/alan2/alan2.cpp
index ccac7a6a02..d875deecb3 100644
--- a/engines/glk/alan2/alan2.cpp
+++ b/engines/glk/alan2/alan2.cpp
@@ -161,8 +161,11 @@ static void syncEventQueue(Common::Serializer &s) {
EvtqElem *arr = eventq;
if (s.isLoading()) {
- for (i = 0; arr[i - 1].time != 0; ++i)
+ i = 0;
+ do {
arr[i].synchronize(s);
+ i++;
+ } while (arr[i - 1].time != 0);
etop = i - 1;
} else {
// Mark the top