Skip to content

Commit

Permalink
Script API: Fix segfault in remove_detached_inventory
Browse files Browse the repository at this point in the history
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
  • Loading branch information
SmallJoker committed Jul 10, 2021
1 parent 42fbc75 commit b93bbfd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/server/serverinventorymgr.cpp
Expand Up @@ -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);
}
Expand Down

0 comments on commit b93bbfd

Please sign in to comment.