diff --git a/rpcs3/Emu/IdManager.h b/rpcs3/Emu/IdManager.h index e8dde8fb8d..a626995ce9 100644 --- a/rpcs3/Emu/IdManager.h +++ b/rpcs3/Emu/IdManager.h @@ -802,9 +802,16 @@ public: { stx::shared_ptr ptr; { + const u32 index = get_index(id); + + if (index >= id_manager::id_traits::count) + { + return false; + } + std::lock_guard lock(id_manager::g_mutex); - if (const auto found = find_id(id); found.first) + if (const auto found = find_index(index, id); found.first) { ptr = found.first->exchange(null_ptr); found.second->clear(); @@ -834,9 +841,16 @@ public: { stx::shared_ptr ptr; { + const u32 index = get_index(id); + + if (index >= id_manager::id_traits::count) + { + return false; + } + [[maybe_unused]] std::conditional_t, const shared_mutex&> lock(id_manager::g_mutex); - if (const auto found = find_id(id); found.first && found.first->is_equal(sptr)) + if (const auto found = find_index(index, id); found.first && found.first->is_equal(sptr)) { ptr = found.first->exchange(null_ptr); found.second->clear(); @@ -866,9 +880,16 @@ public: { stx::shared_ptr ptr; { + const u32 index = get_index(id); + + if (index >= id_manager::id_traits::count) + { + return ptr; + } + [[maybe_unused]] std::conditional_t, const shared_mutex&> lock(id_manager::g_mutex); - if (const auto found = find_id(id); found.first) + if (const auto found = find_index(index, id); found.first) { ptr = static_cast>(found.first->exchange(null_ptr)); found.second->clear();