From 88f346414a5d3456c2930d04956e5e769719d112 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Thu, 28 Oct 2021 10:36:50 +0200 Subject: [PATCH] Fixed race condition when using --no-color --- src/log.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/log.cpp b/src/log.cpp index 9ea46ac..9ee61f6 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -160,7 +160,10 @@ private: p += 3; size -= 3; - if (!CONSOLE_COLORS) { + // Read CONSOLE_COLORS only once because its value can be changed in another thread + const bool c = CONSOLE_COLORS; + + if (!c) { strip_colors(p, size); } @@ -181,7 +184,7 @@ private: } if (m_logFile.is_open()) { - if (CONSOLE_COLORS) { + if (c) { strip_colors(p, size); }