Fixed potential crash in ACS engine

Unknown p-code in compiled script may lead to a crash if the current module was changed during script execution, e.g. by function call
See http://forum.zdoom.org/viewtopic.php?f=2&t=48524
This commit is contained in:
alexey.lysiuk 2015-09-16 16:13:56 +03:00
parent 211f12286a
commit b2fa4970fd
1 changed files with 2 additions and 0 deletions

View File

@ -6032,6 +6032,7 @@ int DLevelScript::RunScript ()
int sp = 0;
int *pc = this->pc;
ACSFormat fmt = activeBehavior->GetFormat();
FBehavior* const savedActiveBehavior = activeBehavior;
unsigned int runaway = 0; // used to prevent infinite loops
int pcd;
FString work;
@ -6065,6 +6066,7 @@ int DLevelScript::RunScript ()
{
default:
Printf ("Unknown P-Code %d in %s\n", pcd, ScriptPresentation(script).GetChars());
activeBehavior = savedActiveBehavior;
// fall through
case PCD_TERMINATE:
DPrintf ("%s finished\n", ScriptPresentation(script).GetChars());