From 7db7886a0ebf0edac38fa574324d29b884ef981f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 14 Jan 2011 09:07:00 +0000 Subject: [PATCH] - fixed: DLevelScript always initialized the first 3 local variables, even if less were allocated. SVN r3101 (trunk) --- src/p_acs.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 8b54ffce2c..60448adaed 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -1964,6 +1964,7 @@ DLevelScript::~DLevelScript () { if (localvars != NULL) delete[] localvars; + localvars = NULL; } void DLevelScript::Unlink () @@ -6725,9 +6726,18 @@ DLevelScript::DLevelScript (AActor *who, line_t *where, int num, const ScriptPtr script = num; numlocalvars = code->VarCount; localvars = new SDWORD[code->VarCount]; - localvars[0] = arg0; - localvars[1] = arg1; - localvars[2] = arg2; + if (code->VarCount > 0) + { + localvars[0] = arg0; + if (code->VarCount > 1) + { + localvars[1] = arg1; + if (code->VarCount > 2) + { + localvars[2] = arg2; + } + } + } memset (localvars+code->ArgCount, 0, (code->VarCount-code->ArgCount)*sizeof(SDWORD)); pc = module->GetScriptAddress (code); activator = who;