Fix segfault in player migration and crash in log_deprecated
authorSmallJoker <mk939@ymail.com>
Mon, 14 May 2018 19:03:48 +0000 (21:03 +0200)
committerSmallJoker <mk939@ymail.com>
Mon, 14 May 2018 19:19:52 +0000 (21:19 +0200)
Makes log_deprecated work when triggered from no function

src/content_sao.cpp
src/script/common/c_internal.cpp

index 1c049c727c208fdf28a848985e594fdd1cbef6aa..6ed78beb081e8ed7ede95868c0068c6cc78603fa 100644 (file)
@@ -1166,8 +1166,12 @@ void PlayerSAO::setBasePosition(const v3f &position)
 
        // This needs to be ran for attachments too
        ServerActiveObject::setBasePosition(position);
-       m_env->updateActiveObject(this);
-       m_position_not_sent = true;
+
+       // Updating is not wanted/required for player migration
+       if (m_env) {
+               m_env->updateActiveObject(this);
+               m_position_not_sent = true;
+       }
 }
 
 void PlayerSAO::setPos(const v3f &pos)
index 3d766a95557c52b347de62c26dd577941ed10e0f..9a24b0e787c139a28229cf67d645517325a41d25 100644 (file)
@@ -153,7 +153,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 << ")";
                }