From 09c8111c53a5adf3ca0e3d28d2b2652cc794efdb Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 12 Feb 2020 14:00:16 +0000 Subject: [PATCH] threadpool: lock mutex in create In some contrived case, it might theoretically be the case that destroy is called from another thread, which would modify the threads array from two threads. Coverity 208372 --- src/common/threadpool.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/threadpool.cpp b/src/common/threadpool.cpp index 18204eeee..753bf238c 100644 --- a/src/common/threadpool.cpp +++ b/src/common/threadpool.cpp @@ -71,6 +71,7 @@ void threadpool::recycle() { } void threadpool::create(unsigned int max_threads) { + const boost::unique_lock lock(mutex); boost::thread::attributes attrs; attrs.set_stack_size(THREAD_STACK_SIZE); max = max_threads ? max_threads : tools::get_max_concurrency();