From 4e0b1a89a688e040bd1bec70084d1f30e2af5381 Mon Sep 17 00:00:00 2001 From: hafo Date: Sat, 20 Jan 2018 01:51:24 -0700 Subject: [PATCH] Check if the strings returned to Tork are nullptrs They should NEVER be nullptrs. This breaks stuff (especially if you have dlls that read the output!!) --- BlocklandLua/main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/BlocklandLua/main.cpp b/BlocklandLua/main.cpp index 7462b10..d69cc70 100644 --- a/BlocklandLua/main.cpp +++ b/BlocklandLua/main.cpp @@ -34,6 +34,9 @@ static const char *ts_luaEval(SimObject *obj, int argc, const char** argv) const char *s = lua_tostring(gL, -1); lua_pop(gL, 1); + if(s == nullptr || s == NULL) { + return ""; + } return s; } @@ -51,6 +54,9 @@ static const char *ts_luaExec(SimObject *obj, int argc, const char** argv) const char *s = lua_tostring(gL, -1); lua_pop(gL, 1); + if(s == nullptr || s == NULL) { + return ""; + } return s; } @@ -69,6 +75,9 @@ static const char *ts_luaCall(SimObject *obj, int argc, const char *argv[]) const char *s = lua_tostring(gL, -1); lua_pop(gL, 1); + if(s == nullptr || s == NULL) { + return ""; + } return s; } @@ -94,6 +103,9 @@ static const char *ts_luaCallAuto(SimObject *obj, int argc, const char *argv[]) const char *s = lua_tostring(gL, -1); lua_pop(gL, 1); + if(s == nullptr || s == NULL) { + return ""; + } return s; }