From 66dc49f7dffebad5e017eb843e486e71fe8e0951 Mon Sep 17 00:00:00 2001 From: Cekis Date: Fri, 26 Nov 2021 15:51:24 -0500 Subject: [PATCH] Added check for logged out client to prevent erase on erased pointer --- src/stationapi/Node.hpp | 2 +- src/stationchat/ChatAvatarService.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/stationapi/Node.hpp b/src/stationapi/Node.hpp index be5235c..08248f8 100644 --- a/src/stationapi/Node.hpp +++ b/src/stationapi/Node.hpp @@ -38,7 +38,7 @@ public: auto remove_iter = std::remove_if(std::begin(clients_), std::end(clients_), [](auto& client) { - return client->GetConnection()->GetStatus() == UdpConnection::cStatusDisconnected; + return client->GetConnection()->GetStatus() == UdpConnection::cStatusDisconnected || client == std::end(clients_); }); if (remove_iter != std::end(clients_)) diff --git a/src/stationchat/ChatAvatarService.cpp b/src/stationchat/ChatAvatarService.cpp index 0de85a3..746dc32 100644 --- a/src/stationchat/ChatAvatarService.cpp +++ b/src/stationchat/ChatAvatarService.cpp @@ -72,6 +72,7 @@ void ChatAvatarService::LoginAvatar(ChatAvatar* avatar) { } void ChatAvatarService::LogoutAvatar(ChatAvatar* avatar) { + if(!avatar->isOnline_) return; avatar->isOnline_ = false; onlineAvatars_.erase(std::remove_if(