diff options
author | SmallJoker <mk939@ymail.com> | 2021-07-10 14:18:35 +0200 |
---|---|---|
committer | SmallJoker <mk939@ymail.com> | 2021-07-10 14:34:36 +0200 |
commit | b93bbfde2c0f6f6217ed3e358ed898049f98e448 (patch) | |
tree | 1cde03957ef1256ea1f257dd0f0893ddd6ca5ac1 /src/server/serverinventorymgr.cpp | |
parent | 42fbc757b110cb48b3bce74a849536f80a0bd272 (diff) | |
download | minetest-b93bbfde2c0f6f6217ed3e358ed898049f98e448.tar.gz minetest-b93bbfde2c0f6f6217ed3e358ed898049f98e448.tar.bz2 minetest-b93bbfde2c0f6f6217ed3e358ed898049f98e448.zip |
Script API: Fix segfault in remove_detached_inventory
when minetest.remove_detached_inventory is called on script init, the environment is yet not set up,
hence m_env is still nullptr until all scripts are loaded
Diffstat (limited to 'src/server/serverinventorymgr.cpp')
-rw-r--r-- | src/server/serverinventorymgr.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/server/serverinventorymgr.cpp b/src/server/serverinventorymgr.cpp index 2a80c9bbe..3aee003b4 100644 --- a/src/server/serverinventorymgr.cpp +++ b/src/server/serverinventorymgr.cpp @@ -157,8 +157,8 @@ bool ServerInventoryManager::removeDetachedInventory(const std::string &name) m_env->getGameDef()->sendDetachedInventory( nullptr, name, player->getPeerId()); - } else { - // Notify all players about the change + } else if (m_env) { + // Notify all players about the change as soon ServerEnv exists m_env->getGameDef()->sendDetachedInventory( nullptr, name, PEER_ID_INEXISTENT); } |