diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 50f50ff31..24142e0ec 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -9716,7 +9716,16 @@ scriptwait: if (runaway != 0 && InModuleScriptNumber >= 0) { - activeBehavior->GetScriptPtr(InModuleScriptNumber)->ProfileData.AddRun(runaway); + auto scriptptr = activeBehavior->GetScriptPtr(InModuleScriptNumber); + if (scriptptr != nullptr) + { + scriptptr->ProfileData.AddRun(runaway); + } + else + { + // It is pointless to continue execution. The script is broken and needs to be aborted. + I_Error("Bad script definition encountered. Script %d is reported running but not present.\nThe most likely cause for this message is using 'delay' inside a function which is not supported.\nPlease check the ACS compiler used for compiling the script!", InModuleScriptNumber); + } } if (state == SCRIPT_DivideBy0)