Skip to content

Commit

Permalink
SCI: Warn more loudly about uninitialised parameter reads
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
csnover committed Nov 20, 2016
1 parent 1015196 commit 11ee0f9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions engines/sci/engine/vm.cpp
Expand Up @@ -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;
}
Expand Down

0 comments on commit 11ee0f9

Please sign in to comment.