diff --git a/Engine/source/console/compiledEval.cpp b/Engine/source/console/compiledEval.cpp index a989826b43..d61a8f3531 100644 --- a/Engine/source/console/compiledEval.cpp +++ b/Engine/source/console/compiledEval.cpp @@ -871,6 +871,7 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi { Con::errorf(ConsoleLogEntry::General, "%s: Unable to instantiate non-SimObject class %s.", getFileLine(ip), (const char*)callArgv[1]); delete object; + currentNewObject = NULL; ip = failJump; break; } @@ -902,6 +903,7 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi // Fail to create the object. delete object; + currentNewObject = NULL; ip = failJump; break; } @@ -1016,6 +1018,7 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi Con::errorf(ConsoleLogEntry::General, "%s: preload failed for %s: %s.", getFileLine(ip), currentNewObject->getName(), errorStr.c_str()); dataBlock->deleteObject(); + currentNewObject = NULL; ip = failJump; // Prevent stack value corruption