Skip to content

Commit

Permalink
wesnothd: add a check to prevent crash from accessing game owner not …
Browse files Browse the repository at this point in the history
…in player_connections_

(cherry-picked from commit 10ee2b2)
  • Loading branch information
loonycyborg committed Oct 7, 2018
1 parent 41aea16 commit 0b9a41c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/server/game.cpp
Expand Up @@ -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_);
Expand Down

0 comments on commit 0b9a41c

Please sign in to comment.