From a1598e1b83e28503745165d5749cd21b77e97818 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Mon, 14 May 2018 21:03:48 +0200 Subject: [PATCH] Fix segfault in player migration and crash in log_deprecated Makes log_deprecated work when triggered from no function --- src/content_sao.cpp | 8 ++++++-- src/script/common/c_internal.cpp | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 1c049c727..6ed78beb0 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -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) diff --git a/src/script/common/c_internal.cpp b/src/script/common/c_internal.cpp index 3d766a955..9a24b0e78 100644 --- a/src/script/common/c_internal.cpp +++ b/src/script/common/c_internal.cpp @@ -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 << ")"; } -- 2.25.1