From 6e23c39d40031933c22d52bf266b7632f91ccf0b Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 22 Feb 2024 02:00:09 +0100 Subject: [PATCH] Netconsole: fix race condition caused by misplaced mutex Mutex should be locked before IsConnected(), as IsConnected() accesses CSocketCreator which checks a vector (not thread safe), lock the mutex in the correct place. --- src/netconsole/netconsole.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/netconsole/netconsole.cpp b/src/netconsole/netconsole.cpp index c3e29039..7620fd28 100644 --- a/src/netconsole/netconsole.cpp +++ b/src/netconsole/netconsole.cpp @@ -278,10 +278,10 @@ bool CNetCon::RunFrame(void) { if (IsInitialized()) { + std::lock_guard l(m_Mutex); + if (IsConnected()) { - std::lock_guard l(m_Mutex); - CConnectedNetConsoleData& pData = GetSocketCreator()->GetAcceptedSocketData(0); Recv(pData); }