From c9609fbdbf094ee3800f7e117b1371eeed3cfc67 Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sun, 4 Aug 2019 11:20:01 +0200 Subject: [PATCH] CInterface integration in CodeInterpreter null ptr fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mNSEntry can be null if there is no TorqueScript defintion, but there could still be a result from an externally defined source. ยด Furthermore fixes an issue where StringStackConsoleWrapper would die before the value was read. --- Engine/source/console/codeInterpreter.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Engine/source/console/codeInterpreter.cpp b/Engine/source/console/codeInterpreter.cpp index 8099ac575..434d8d2c8 100644 --- a/Engine/source/console/codeInterpreter.cpp +++ b/Engine/source/console/codeInterpreter.cpp @@ -2181,14 +2181,15 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip) // ConsoleFunctionType is for any function defined by script. // Any 'callback' type is an engine function that is exposed to script. - if (mNSEntry->mType == Namespace::Entry::ConsoleFunctionType - || cFunctionRes) + if (cFunctionRes || mNSEntry->mType == Namespace::Entry::ConsoleFunctionType) { + ConsoleValue retVal; ConsoleValueRef ret; if (cFunctionRes) { - StringStackConsoleWrapper retVal(1, &cRetRes); - ret = retVal.argv[0]; + retVal.init(); + ret.value = &retVal; + retVal.setStackStringValue(cRetRes); } else if (mNSEntry->mFunctionOffset) {