Fix minetest.request_insecure_environment() always returning nil
authorJeija <norrepli@gmail.com>
Thu, 25 Feb 2016 08:47:28 +0000 (09:47 +0100)
committerest31 <MTest31@outlook.com>
Fri, 26 Feb 2016 05:36:48 +0000 (06:36 +0100)
Fixes #3765

src/script/lua_api/l_util.cpp

index c04f09f9016232e4ebb4fe079e5180deb2244552..cc4467bb61bec5bc27d570c411947434b92b343e 100644 (file)
@@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "cpp_api/s_security.h"
 #include "areastore.h"
 #include "porting.h"
+#include "debug.h"
 #include "log.h"
 #include "tool.h"
 #include "filesys.h"
@@ -372,8 +373,8 @@ int ModApiUtil::l_request_insecure_environment(lua_State *L)
        if (lua_getstack(L, 2, &info)) {
                return 0;
        }
-       assert(lua_getstack(L, 1, &info));
-       assert(lua_getinfo(L, "S", &info));
+       FATAL_ERROR_IF(!lua_getstack(L, 1, &info), "lua_getstack() failed");
+       FATAL_ERROR_IF(!lua_getinfo(L, "S", &info), "lua_getinfo() failed");
        // ...and that that item is the main file scope.
        if (strcmp(info.what, "main") != 0) {
                return 0;