diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index 0d97ec26ab..40b4f1703a 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -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 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)); }