diff --git a/Core/Util/BlockAllocator.cpp b/Core/Util/BlockAllocator.cpp index 652ea2499a..27183cbff8 100644 --- a/Core/Util/BlockAllocator.cpp +++ b/Core/Util/BlockAllocator.cpp @@ -191,17 +191,19 @@ restart: } } -void BlockAllocator::Free(u32 position) +bool BlockAllocator::Free(u32 position) { BlockAllocator::Block *b = GetBlockFromAddress(position); - if (b) + if (b && b->taken) { b->taken = false; MergeFreeBlocks(); + return true; } else { ERROR_LOG(HLE, "BlockAllocator : invalid free %08x", position); + return false; } } diff --git a/Core/Util/BlockAllocator.h b/Core/Util/BlockAllocator.h index dc90b1dd8b..7ed26d3fc6 100644 --- a/Core/Util/BlockAllocator.h +++ b/Core/Util/BlockAllocator.h @@ -26,7 +26,7 @@ public: u32 Alloc(u32 &size, bool fromTop = false, const char *tag = 0); u32 AllocAt(u32 position, u32 size, const char *tag = 0); - void Free(u32 position); + bool Free(u32 position); bool IsBlockFree(u32 position) { Block *b = GetBlockFromAddress(position); if (b) @@ -53,14 +53,15 @@ private: } void SetTag(const char *_tag) { if (_tag) - strcpy(tag, _tag); + strncpy(tag, _tag, 32); else - strcpy(tag, "---"); + strncpy(tag, "---", 32); + tag[31] = 0; } u32 start; u32 size; bool taken; - char tag[16]; + char tag[32]; }; std::list blocks;