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';