From 8ce2be57c58459eb1f0b28f1d192c911dc9c84e5 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 29 Nov 2023 19:16:32 +1000 Subject: [PATCH] CPU/CodeCache: Call Block constructor/destructor Fixes crash in MSVC Debug build. --- src/core/cpu_code_cache.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/cpu_code_cache.cpp b/src/core/cpu_code_cache.cpp index caa1df271..d5eac4954 100644 --- a/src/core/cpu_code_cache.cpp +++ b/src/core/cpu_code_cache.cpp @@ -442,6 +442,7 @@ CPU::CodeCache::Block* CPU::CodeCache::CreateBlock(u32 pc, const BlockInstructio Assert(it != s_blocks.end()); s_blocks.erase(it); + block->~Block(); std::free(block); block = nullptr; } @@ -452,6 +453,7 @@ CPU::CodeCache::Block* CPU::CodeCache::CreateBlock(u32 pc, const BlockInstructio block = static_cast(std::malloc(sizeof(Block) + (sizeof(Instruction) * size) + (sizeof(InstructionInfo) * size))); Assert(block); + new (block) Block(); s_blocks.push_back(block); } @@ -710,7 +712,10 @@ void CPU::CodeCache::ClearBlocks() #endif for (Block* block : s_blocks) + { + block->~Block(); std::free(block); + } s_blocks.clear(); std::memset(s_lut_block_pointers.get(), 0, sizeof(Block*) * GetLUTSlotCount(false));