From 8934a4bc4d4135e30e8663bee8b6154230d58a9e Mon Sep 17 00:00:00 2001 From: Wiebe Cazemier Date: Sun, 10 Jul 2022 17:33:10 +0200 Subject: [PATCH] Prevent insertion of null clients in client list --- threaddata.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/threaddata.cpp b/threaddata.cpp index 55a3aff..47cef0a 100644 --- a/threaddata.cpp +++ b/threaddata.cpp @@ -294,7 +294,13 @@ void ThreadData::giveClient(std::shared_ptr client) std::shared_ptr ThreadData::getClient(int fd) { std::lock_guard lck(clients_by_fd_mutex); - return this->clients_by_fd[fd]; + + auto pos = clients_by_fd.find(fd); + + if (pos == clients_by_fd.end()) + return std::shared_ptr(); + + return pos->second; } void ThreadData::removeClientQueued(const std::shared_ptr &client) -- libgit2 0.21.4