From 1526355589b6cb29df4d1d18bf7554a5f1f251d6 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 11 Dec 2020 21:59:21 -0800 Subject: GLTF resource manager: fixed issue with allocation cache not being protected by mutex --- AssetLoader/src/GLTFResourceManager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'AssetLoader/src/GLTFResourceManager.cpp') diff --git a/AssetLoader/src/GLTFResourceManager.cpp b/AssetLoader/src/GLTFResourceManager.cpp index 54c3416..f3b8b8b 100644 --- a/AssetLoader/src/GLTFResourceManager.cpp +++ b/AssetLoader/src/GLTFResourceManager.cpp @@ -126,8 +126,10 @@ RefCntAutoPtr ResourceManager::AllocateTextureSpace( if (CacheId != nullptr && *CacheId != 0) { - auto inserted = m_TexAllocations.emplace(CacheId, pAllocation).second; - VERIFY_EXPR(inserted); + std::lock_guard Lock{m_TexAllocationsMtx}; + // Note that the same allocation may potentially be created by more + // than one thread if it has not been found in the cache originally + m_TexAllocations.emplace(CacheId, pAllocation).second; } return pAllocation; -- cgit v1.2.3