Skip to content

Commit 836486a

Browse files
committedOct 16, 2015
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]: b5acec0 "Add proper lua api deprecated handling" [2]: 7b8d372 "Use warningstream for deprecated field messages and refactor log_deprecated"
1 parent b600bc3 commit 836486a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

Diff for: ‎src/script/common/c_internal.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,14 @@ void log_deprecated(lua_State *L, const std::string &message)
179179

180180
if (do_log) {
181181
warningstream << message << std::endl;
182-
if (do_error)
183-
script_error(L, LUA_ERRRUN, NULL, NULL);
184-
else
185-
infostream << script_get_backtrace(L) << std::endl;
182+
// L can be NULL if we get called by log_deprecated(const std::string &msg)
183+
// from scripting_game.cpp.
184+
if (L) {
185+
if (do_error)
186+
script_error(L, LUA_ERRRUN, NULL, NULL);
187+
else
188+
infostream << script_get_backtrace(L) << std::endl;
189+
}
186190
}
187191
}
188192

0 commit comments

Comments
 (0)
Please sign in to comment.