From b1fae3ccda06dce30fabdc0f3ff527bad40570fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 16 Sep 2024 14:59:58 +0200 Subject: [PATCH] Add two missing mutex-locks in MetaFileSystem. See #19272 --- Core/FileSystems/MetaFileSystem.cpp | 3 +++ Core/FileSystems/MetaFileSystem.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index 8fba8dff00..adc86c0ebb 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -292,12 +292,14 @@ void MetaFileSystem::Mount(const std::string &prefix, std::shared_ptr guard(lock); for (auto iter = fileSystems.begin(); iter != fileSystems.end(); iter++) { if (iter->prefix == prefix) { fileSystems.erase(iter); @@ -325,6 +327,7 @@ IFileSystem *MetaFileSystem::GetSystemFromFilename(const std::string &filename) } IFileSystem *MetaFileSystem::GetSystem(const std::string &prefix) { + std::lock_guard guard(lock); for (auto it = fileSystems.begin(); it != fileSystems.end(); ++it) { if (it->prefix == NormalizePrefix(prefix)) return it->system.get(); diff --git a/Core/FileSystems/MetaFileSystem.h b/Core/FileSystems/MetaFileSystem.h index a735106f68..0a2255566f 100644 --- a/Core/FileSystems/MetaFileSystem.h +++ b/Core/FileSystems/MetaFileSystem.h @@ -43,8 +43,9 @@ private: currentDir_t currentDir; std::string startingDirectory; - std::recursive_mutex lock; // must be recursive + std::recursive_mutex lock; // must be recursive. TODO: fix that + // Assumes the lock is held void Reset() { // This used to be 6, probably an attempt to replicate PSP handles. // However, that's an artifact of using psplink anyway...