From 704ee84d79600be3a3bbc182e9fc2819748ae2cf Mon Sep 17 00:00:00 2001 From: Daan Steenbergen Date: Fri, 15 Mar 2024 23:01:53 +0100 Subject: [PATCH] fix(vt): correctly scope lock guard + add missing iterate-to-next in for loop --- isobus/src/isobus_virtual_terminal_client.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/isobus/src/isobus_virtual_terminal_client.cpp b/isobus/src/isobus_virtual_terminal_client.cpp index 054164cc..b8af3ec6 100644 --- a/isobus/src/isobus_virtual_terminal_client.cpp +++ b/isobus/src/isobus_virtual_terminal_client.cpp @@ -4503,11 +4503,11 @@ namespace isobus return true; } + LOCK_GUARD(Mutex, commandQueueMutex); if (replace && replace_command(data)) { return true; } - LOCK_GUARD(Mutex, commandQueueMutex); commandQueue.emplace_back(data); return true; } @@ -4531,6 +4531,10 @@ namespace isobus it = commandQueue.erase(it); } } + else + { + it++; + } } return alreadyReplaced; }