aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2017-11-29 18:42:30 -0600
committerColin Snover2017-12-01 19:39:30 -0600
commit4d3f05ae7928ba625f29749b73b754314bdbe728 (patch)
tree5995469cf1d2f394a6b11f1def70c985af654430
parent2b5605362abeb351132d7bf58d18790a8c6fabfe (diff)
downloadscummvm-rg350-4d3f05ae7928ba625f29749b73b754314bdbe728.tar.gz
scummvm-rg350-4d3f05ae7928ba625f29749b73b754314bdbe728.tar.bz2
scummvm-rg350-4d3f05ae7928ba625f29749b73b754314bdbe728.zip
SCUMM: Fix array overflow writing var when no current script is set
This situation is triggered normally when _currentScript is 0xFF, but it could potentially also happen if _currentScript is some other number >= NUM_SCRIPT_SLOT, so the check is a bit more conservative than it might appear to need to be.
-rw-r--r--engines/scumm/script.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp
index c9b37d43b1..36a5fdb8f3 100644
--- a/engines/scumm/script.cpp
+++ b/engines/scumm/script.cpp
@@ -651,7 +651,7 @@ void ScummEngine::writeVar(uint var, int value) {
_scummVars[var] = value;
- if ((_varwatch == (int)var) || (_varwatch == 0)) {
+ if ((_varwatch == (int)var || _varwatch == 0) && _currentScript < NUM_SCRIPT_SLOT) {
if (vm.slot[_currentScript].number < 100)
debug(1, "vars[%d] = %d (via script-%d)", var, value, vm.slot[_currentScript].number);
else