Fix crash in log_deprecated when triggered from no function
authorSmallJoker <mk939@ymail.com>
Mon, 14 May 2018 19:03:48 +0000 (21:03 +0200)
committersfan5 <sfan5@live.de>
Sun, 10 Jun 2018 15:18:11 +0000 (17:18 +0200)
Based on commit a1598e1b

src/script/common/c_internal.cpp

index 3fa0441725a57e36e226330d4573b73d3ef5ef07..3e28d9cf6288e9cb508a9ac4ae4f577dcb026e5d 100644 (file)
@@ -181,7 +181,9 @@ void log_deprecated(lua_State *L, const std::string &message)
                warningstream << message;
                if (L) { // L can be NULL if we get called from scripting_game.cpp
                        lua_Debug ar;
-                       FATAL_ERROR_IF(!lua_getstack(L, 2, &ar), "lua_getstack() failed");
+
+                       if (!lua_getstack(L, 2, &ar))
+                               FATAL_ERROR_IF(!lua_getstack(L, 1, &ar), "lua_getstack() failed");
                        FATAL_ERROR_IF(!lua_getinfo(L, "Sl", &ar), "lua_getinfo() failed");
                        warningstream << " (at " << ar.short_src << ":" << ar.currentline << ")";
                }