wesnothd: add a check to prevent crash from accessing game owner not in player_connections_
This commit is contained in:
parent
c580156716
commit
10ee2b2d29
1 changed files with 5 additions and 1 deletions
|
@ -1528,7 +1528,11 @@ bool game::remove_player(const socket_ptr& player, const bool disconnect, const
|
|||
// Check whether the host is actually a player and make him one if not.
|
||||
if(!is_player(owner_)) {
|
||||
DBG_GAME << "making the owner a player...\n";
|
||||
player_connections_.find(owner_)->info().set_status(player::PLAYING);
|
||||
auto owner_iter = player_connections_.find(owner_);
|
||||
if(owner_iter == player_connections_.end())
|
||||
ERR_GAME << "game owner " << client_address(owner_) << "is not in player_connections_\n";
|
||||
else
|
||||
owner_iter->info().set_status(player::PLAYING);
|
||||
observers_.erase(std::remove(observers_.begin(), observers_.end(), owner_), observers_.end());
|
||||
players_.push_back(owner_);
|
||||
send_observerquit(owner_);
|
||||
|
|
Loading…
Add table
Reference in a new issue