From 830f371fad3569fe1ea01ef78e841eaa85fb0741 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sun, 1 Nov 2026 01:43:14 +0000 Subject: [PATCH] Maintenance: CCommonObject buffers: the original Clear (fn_03417 @0x5B7C90) frees each buffer with operator delete[] (call 0xE62E9E, Batch #9108 by ragnarok-clanker: forced by an admin (1 lower score(s), 2 changed function(s)); checked with 1 compiled unit(s). --- Source/File/CommonObject.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Source/File/CommonObject.cpp b/Source/File/CommonObject.cpp index 11b3c53c..8a766e43 100644 --- a/Source/File/CommonObject.cpp +++ b/Source/File/CommonObject.cpp @@ -15,7 +15,7 @@ CCommonObject::~CCommonObject() { // FUNCTION: fn_03417 void CCommonObject::Clear() { for (char* buffer : this->m_buffers) { - std::free(buffer); + delete[] buffer; } this->m_buffers.clear(); @@ -36,12 +36,7 @@ bool CCommonObject::LoadTokens(std::vector& tokens, const char* name, int } const auto bytes = static_cast(file.Size()); - std::unique_ptr buffer(static_cast(std::malloc(static_cast(bytes) + 1)), &std::free); - - if (!buffer) { - file.Close(); - throw std::bad_alloc(); - } + std::unique_ptr buffer(new char[static_cast(bytes) + 1]); std::memcpy(buffer.get(), file.Data(), bytes); buffer.get()[bytes] = '\0';