From 836486a98e7b09e25b97c9d989301ed9eb365b3b Mon Sep 17 00:00:00 2001 From: est31 Date: Sat, 17 Oct 2015 01:01:12 +0200 Subject: [PATCH] Fix crash regression when invsize formspec gets used The invsize formspec element is outdated. Even though, it is still supported, only a deprecation warning is shown, introduced by commit [1]. The lua context passed to the log_deprecated method added by commit [1] is NULL for the invsize deprecation warning, as its run on the client and not the server. Commit [1] has removed checks for NULL inside the log_deprecated method, resulting in a crash when a formspec with an invsize element is parsed. This commit puts the check back. Fixes #3260. Referenced commits: [1]: b5acec0a3c5701c53854ff7afdf4008863e6e8df "Add proper lua api deprecated handling" [2]: 7b8d372947aae232ddf598155e972bb4dda157a "Use warningstream for deprecated field messages and refactor log_deprecated" --- src/script/common/c_internal.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/script/common/c_internal.cpp b/src/script/common/c_internal.cpp index 073ff1541..b349f9dd1 100644 --- a/src/script/common/c_internal.cpp +++ b/src/script/common/c_internal.cpp @@ -179,10 +179,14 @@ void log_deprecated(lua_State *L, const std::string &message) if (do_log) { warningstream << message << std::endl; - if (do_error) - script_error(L, LUA_ERRRUN, NULL, NULL); - else - infostream << script_get_backtrace(L) << std::endl; + // L can be NULL if we get called by log_deprecated(const std::string &msg) + // from scripting_game.cpp. + if (L) { + if (do_error) + script_error(L, LUA_ERRRUN, NULL, NULL); + else + infostream << script_get_backtrace(L) << std::endl; + } } }