From 8d21b98ac61e6ea5ecbc1e3ad8c6241ae531ff64 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Thu, 6 Aug 2020 17:01:24 -0400 Subject: [PATCH] Ensure lock is held when accessing open devices --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 3e50184..f19c4c7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -275,6 +275,7 @@ void searchForDevices() { return; auto canMessage = std::static_pointer_cast(message); const OpenDevice* openDevice = nullptr; + std::lock_guard lg(openDevicesMutex); for(const auto& dev : openDevices) { if(dev.device->getSerial() == serial) { openDevice = &dev; @@ -482,6 +483,7 @@ int main(int argc, char** argv) { msg->data = currentPosition; currentPosition += msg->length; bool sent = false; + std::lock_guard lg(openDevicesMutex); for(auto& dev : openDevices) { for(auto& netifPair : dev.interfaces) { if(netifPair.second->getKernelHandle() != msg->netid)