From 79e1ea02ab6dbdecbdfa1bf3602b50028860fa27 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Sun, 8 Nov 2020 16:25:47 +0000 Subject: [PATCH] simgear/debug/logdelta.cxx: protect cache with a std::mutex. --- simgear/debug/logdelta.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/simgear/debug/logdelta.cxx b/simgear/debug/logdelta.cxx index 6efe42ec..00630d4a 100644 --- a/simgear/debug/logdelta.cxx +++ b/simgear/debug/logdelta.cxx @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -137,6 +138,8 @@ struct logDelta if (!function) function = ""; logDeltaCacheItem flf(file, line, function); + std::lock_guard lock( m_mutex); + auto it = m_cache.find(flf); if (it == m_cache.end()) { @@ -212,6 +215,7 @@ struct logDelta } private: + std::mutex m_mutex; std::map m_cache; std::vector m_items; };