aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2016-11-19 12:58:12 -0600
committerColin Snover2016-11-19 19:05:38 -0600
commit11ee0f90ac67a3ee0a36506c35e35af6a11f7936 (patch)
tree3b9355ead3464ef33b06bf905f0ac4ed8f0c1910
parent10151966a6e1ae58f01d37e6fb110c7f740c96ba (diff)
downloadscummvm-rg350-11ee0f90ac67a3ee0a36506c35e35af6a11f7936.tar.gz
scummvm-rg350-11ee0f90ac67a3ee0a36506c35e35af6a11f7936.tar.bz2
scummvm-rg350-11ee0f90ac67a3ee0a36506c35e35af6a11f7936.zip
SCI: Warn more loudly about uninitialised parameter reads
Silently returning zero values can cause games to break. e.g. Shivers 1 room 35170 has a script bug where vJoystick::handleEvent makes a super call which causes doVerb to be called a second time with no arguments. In the original game this happened to work because the value already on the stack happened to be 1. In ScummVM this silently (unless VM debug messages were enabled) failed because the uninitialised read value was forced to 0.
-rw-r--r--engines/sci/engine/vm.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index a6d37d05ef..ac15aebf3a 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -142,11 +142,13 @@ static reg_t read_var(EngineState *s, int type, int index) {
s->variables[type][index] = make_reg(0, solution.value);
break;
}
- case VAR_PARAM:
+ case VAR_PARAM: {
// Out-of-bounds read for a parameter that goes onto stack and hits an uninitialized temp
// We return 0 currently in that case
- debugC(kDebugLevelVM, "[VM] Read for a parameter goes out-of-bounds, onto the stack and gets uninitialized temp");
+ const SciCallOrigin origin = s->getCurrentCallOrigin();
+ warning("Uninitialized read for parameter %d from %s", index, origin.toString().c_str());
return NULL_REG;
+ }
default:
break;
}