From 1761d7d0f8a778e25ca70216520472a61610cbe5 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 3 Mar 2020 20:44:03 +0100 Subject: [PATCH] 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). --- src/script/lua_api/l_env.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); }