Do not allow the VM to run on non-existent scripts (which shouldn't be happening anymore)

svn-id: r50276
This commit is contained in:
Filippos Karapetis 2010-06-25 17:13:47 +00:00
parent ab19e87414
commit b6d1b3bc0b

View File

@ -826,22 +826,12 @@ void run_vm(EngineState *s, bool restoring) {
return; // Stop processing
if (s->_executionStackPosChanged) {
Script *scr;
Script *scr = s->_segMan->getScriptIfLoaded(s->xs->addr.pc.segment);
if (!scr)
error("No script in segment %d", s->xs->addr.pc.segment);
s->xs = &(s->_executionStack.back());
s->_executionStackPosChanged = false;
scr = s->_segMan->getScriptIfLoaded(s->xs->addr.pc.segment);
if (!scr) {
// No script? Implicit return via fake instruction buffer
// FIXME: Why does this happen? Are there leftover calls in the call stack?
warning("Running on non-existant script in segment %x", s->xs->addr.pc.segment);
code_buf = _fake_return_buffer;
code_buf_size = 2;
s->xs->addr.pc.offset = 1;
scr = NULL;
obj = NULL;
} else {
obj = s->_segMan->getObject(s->xs->objp);
code_buf = scr->_buf;
code_buf_size = scr->getBufSize();
@ -853,7 +843,6 @@ void run_vm(EngineState *s, bool restoring) {
s->variablesBase[VAR_LOCAL] = s->variables[VAR_LOCAL] = NULL;
s->variablesMax[VAR_LOCAL] = 0;
} else {
s->variablesSegment[VAR_LOCAL] = local_script->_localsSegment;
if (local_script->_localsBlock)
s->variablesBase[VAR_LOCAL] = s->variables[VAR_LOCAL] = local_script->_localsBlock->_locals.begin();
@ -870,8 +859,6 @@ void run_vm(EngineState *s, bool restoring) {
s->variables[VAR_PARAM] = s->xs->variables_argp;
}
}
if (s->abortScriptProcessing != kAbortNone || g_engine->shouldQuit())
return; // Stop processing