Added bounds check for local variables in ACS VM
This commit is contained in:
parent
df0cddb35d
commit
44f01e1dc6
2 changed files with 46 additions and 9 deletions
|
|
@ -644,7 +644,7 @@ inline int PitchToACS(DAngle ang)
|
|||
|
||||
struct CallReturn
|
||||
{
|
||||
CallReturn(int pc, ScriptFunction *func, FBehavior *module, int32_t *locals, ACSLocalArrays *arrays, bool discard, unsigned int runaway)
|
||||
CallReturn(int pc, ScriptFunction *func, FBehavior *module, const ACSLocalVariables &locals, ACSLocalArrays *arrays, bool discard, unsigned int runaway)
|
||||
: ReturnFunction(func),
|
||||
ReturnModule(module),
|
||||
ReturnLocals(locals),
|
||||
|
|
@ -656,7 +656,7 @@ struct CallReturn
|
|||
|
||||
ScriptFunction *ReturnFunction;
|
||||
FBehavior *ReturnModule;
|
||||
int32_t *ReturnLocals;
|
||||
ACSLocalVariables ReturnLocals;
|
||||
ACSLocalArrays *ReturnArrays;
|
||||
int ReturnAddress;
|
||||
int bDiscardResult;
|
||||
|
|
@ -6967,7 +6967,7 @@ static void SetMarineSprite(AActor *marine, PClassActor *source)
|
|||
int DLevelScript::RunScript ()
|
||||
{
|
||||
DACSThinker *controller = DACSThinker::ActiveThinker;
|
||||
int32_t *locals = &Localvars[0];
|
||||
ACSLocalVariables locals(Localvars);
|
||||
ACSLocalArrays noarrays;
|
||||
ACSLocalArrays *localarrays = &noarrays;
|
||||
ScriptFunction *activeFunction = NULL;
|
||||
|
|
@ -7335,7 +7335,6 @@ int DLevelScript::RunScript ()
|
|||
int i;
|
||||
ScriptFunction *func;
|
||||
FBehavior *module;
|
||||
int32_t *mylocals;
|
||||
|
||||
if(pcd == PCD_CALLSTACK)
|
||||
{
|
||||
|
|
@ -7364,9 +7363,9 @@ int DLevelScript::RunScript ()
|
|||
state = SCRIPT_PleaseRemove;
|
||||
break;
|
||||
}
|
||||
mylocals = locals;
|
||||
const ACSLocalVariables mylocals = locals;
|
||||
// The function's first argument is also its first local variable.
|
||||
locals = &Stack[sp - func->ArgCount];
|
||||
locals.Reset(&Stack[sp - func->ArgCount], func->ArgCount + func->LocalCount);
|
||||
// Make space on the stack for any other variables the function uses.
|
||||
for (i = 0; i < func->LocalCount; ++i)
|
||||
{
|
||||
|
|
@ -7405,7 +7404,7 @@ int DLevelScript::RunScript ()
|
|||
sp -= sizeof(CallReturn)/sizeof(int);
|
||||
retsp = &Stack[sp];
|
||||
activeBehavior->GetFunctionProfileData(activeFunction)->AddRun(runaway - ret->EntryInstrCount);
|
||||
sp = int(locals - &Stack[0]);
|
||||
sp = int(locals.GetPointer() - &Stack[0]);
|
||||
pc = ret->ReturnModule->Ofs2PC(ret->ReturnAddress);
|
||||
activeFunction = ret->ReturnFunction;
|
||||
activeBehavior = ret->ReturnModule;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue