summaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2020-03-03 20:44:03 +0100
committersfan5 <sfan5@live.de>2020-03-03 21:21:41 +0100
commit1761d7d0f8a778e25ca70216520472a61610cbe5 (patch)
tree4042f2c0f875c44c4ff24bd440b93485bd3228e9 /src/script/lua_api
parent7dffd08c1a068e5e0748a046fd8a1e884947b597 (diff)
downloadminetest-1761d7d0f8a778e25ca70216520472a61610cbe5.tar.gz
minetest-1761d7d0f8a778e25ca70216520472a61610cbe5.tar.bz2
minetest-1761d7d0f8a778e25ca70216520472a61610cbe5.zip
Fix core.get_connected_players() returning unusable ObjectRefs
This bug is only exposed by 91eef646a59575bd9ae792e257bb6ad12fafc0b1 independent of the move of get_connected_players from Lua to C++. Previously, there would be a small time window where the SAO had its peer ID set to PEER_ID_INEXISTENT but the RemotePlayer was still linked to the SAO, resulting in an ObjectRef that crashed on certain function calls (#9387).
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_env.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index ac52941b3..6e67e547b 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -651,7 +651,7 @@ int ModApiEnvMod::l_get_connected_players(lua_State *L)
if (player->getPeerId() == PEER_ID_INEXISTENT)
continue;
PlayerSAO *sao = player->getPlayerSAO();
- if (sao) {
+ if (sao && !sao->isGone()) {
getScriptApiBase(L)->objectrefGetOrCreate(L, sao);
lua_rawseti(L, -2, ++i);
}