Skip to content

Commit

Permalink
Fix crash regression when invsize formspec gets used
Browse files Browse the repository at this point in the history
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"
  • Loading branch information
est31 committed Oct 16, 2015
1 parent b600bc3 commit 836486a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/script/common/c_internal.cpp
Expand Up @@ -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;
}
}
}

0 comments on commit 836486a

Please sign in to comment.