Check validity of iterator before dereferencing
This commit is contained in:
parent
fdfa14d9cc
commit
8857db9833
|
@ -316,12 +316,15 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
|
|||
PlayerId pid;
|
||||
packet >> pid;
|
||||
|
||||
INFO_LOG(NETPLAY, "Player %s (%d) left", m_players.find(pid)->second.name.c_str(), pid);
|
||||
|
||||
m_dialog->OnPlayerDisconnect(m_players.find(pid)->second.name);
|
||||
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
|
||||
const auto it = m_players.find(pid);
|
||||
if (it == m_players.end())
|
||||
break;
|
||||
|
||||
const auto& player = it->second;
|
||||
INFO_LOG(NETPLAY, "Player %s (%d) left", player.name.c_str(), pid);
|
||||
m_dialog->OnPlayerDisconnect(player.name);
|
||||
m_players.erase(m_players.find(pid));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue