From dff1ebaf21ae52e27e9915a26fbf535d3ab149ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Tue, 26 Mar 2019 23:46:08 +0100 Subject: [PATCH] Apply better guards for download queueing (#8864) Follow-up to #8821. Use mutex to synchronize access rather than make the bool atomic to avoid TOCTOU issues. --- src/openrct2-ui/windows/ObjectLoadError.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/openrct2-ui/windows/ObjectLoadError.cpp b/src/openrct2-ui/windows/ObjectLoadError.cpp index 3624587123..fa8ea6855a 100644 --- a/src/openrct2-ui/windows/ObjectLoadError.cpp +++ b/src/openrct2-ui/windows/ObjectLoadError.cpp @@ -34,6 +34,7 @@ private: std::vector _downloadedEntries; size_t _currentDownloadIndex{}; std::mutex _downloadedEntriesMutex; + std::mutex _queueMutex; bool _nextDownloadQueued{}; // TODO static due to INTENT_EXTRA_CALLBACK not allowing a std::function @@ -61,6 +62,7 @@ public: void Update() { + std::lock_guard guard(_queueMutex); if (_nextDownloadQueued) { _nextDownloadQueued = false; @@ -87,6 +89,7 @@ private: void QueueNextDownload() { + std::lock_guard guard(_queueMutex); _nextDownloadQueued = true; }