From 12134ceb2b87e0f180eb67f44e2fafd5ec66d49e Mon Sep 17 00:00:00 2001 From: Jeff Hutchinson Date: Tue, 10 Apr 2018 22:21:40 -0400 Subject: [PATCH] Check for NULL on the thisObject before using it. Also cleanup break to goto. --- Engine/source/console/codeInterpreter.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Engine/source/console/codeInterpreter.cpp b/Engine/source/console/codeInterpreter.cpp index 46d58476e..cd25d47f3 100644 --- a/Engine/source/console/codeInterpreter.cpp +++ b/Engine/source/console/codeInterpreter.cpp @@ -400,11 +400,11 @@ ConsoleValueRef CodeInterpreter::exec(U32 ip, breakContinueLabel: OPCodeReturn ret = (this->*gOpCodeArray[mCurrentInstruction])(ip); if (ret == OPCodeReturn::exitCode) - goto exitLabel; + break; else if (ret == OPCodeReturn::breakContinue) goto breakContinueLabel; } -exitLabel: + if (telDebuggerOn && setFrame < 0) TelDebugger->popStackFrame(); @@ -2133,7 +2133,7 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip) if (!mExec.noCalls && !(routingId == MethodOnComponent)) { Con::warnf(ConsoleLogEntry::General, "%s: Unknown command %s.", mCodeBlock->getFileLine(ip - 6), fnName); - if (callType == FuncCallExprNode::MethodCall) + if (callType == FuncCallExprNode::MethodCall && gEvalState.thisObject != NULL) { Con::warnf(ConsoleLogEntry::General, " Object %s(%d) %s", gEvalState.thisObject->getName() ? gEvalState.thisObject->getName() : "", @@ -2522,9 +2522,17 @@ OPCodeReturn CodeInterpreter::op_callfunc_this(U32 &ip) if (!mExec.noCalls) { Con::warnf(ConsoleLogEntry::General, "%s: Unknown command %s.", mCodeBlock->getFileLine(ip - 6), fnName); - Con::warnf(ConsoleLogEntry::General, " Object %s(%d) %s", - mThisObject->getName() ? mThisObject->getName() : "", - mThisObject->getId(), Con::getNamespaceList(ns)); + if (mThisObject) + { + Con::warnf(ConsoleLogEntry::General, " Object %s(%d) %s", + mThisObject->getName() ? mThisObject->getName() : "", + mThisObject->getId(), Con::getNamespaceList(ns)); + } + else + { + // At least let the scripter know that they access the object. + Con::warnf(ConsoleLogEntry::General, " Object is NULL."); + } } STR.popFrame(); CSTK.popFrame();