wesnothd: fix crash from using reference to deleted object
This commit is contained in:
parent
04d0dcdf65
commit
b0cbe3adf7
1 changed files with 5 additions and 2 deletions
|
@ -1292,6 +1292,7 @@ void server::handle_player_in_game(socket_ptr socket, std::shared_ptr<simple_wml
|
|||
auto p = player_connections_.find(socket);
|
||||
wesnothd::player& player = p->info();
|
||||
game& g = *(p->get_game());
|
||||
std::weak_ptr<game> g_ptr { p->get_game() };
|
||||
|
||||
simple_wml::document& data = *doc;
|
||||
|
||||
|
@ -1478,14 +1479,16 @@ void server::handle_player_in_game(socket_ptr socket, std::shared_ptr<simple_wml
|
|||
// ones so he gets the updated gamelist.
|
||||
delete_game(g.id());
|
||||
} else {
|
||||
auto description = g.description();
|
||||
g.remove_player(socket);
|
||||
player_connections_.modify(player_connections_.find(socket), player_record::enter_lobby);
|
||||
g.describe_slots();
|
||||
if(!g_ptr.expired())
|
||||
g.describe_slots();
|
||||
|
||||
// Send all other players in the lobby the update to the gamelist.
|
||||
simple_wml::document diff;
|
||||
bool diff1 = make_change_diff(*games_and_users_list_.child("gamelist"),
|
||||
"gamelist", "game", g.description(), diff);
|
||||
"gamelist", "game", description, diff);
|
||||
bool diff2 = make_change_diff(games_and_users_list_.root(), nullptr,
|
||||
"user", player.config_address(), diff);
|
||||
if (diff1 || diff2) {
|
||||
|
|
Loading…
Add table
Reference in a new issue