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).
This commit is contained in:
parent
145cf03e5d
commit
830f371fad
1 changed files with 2 additions and 7 deletions
|
|
@ -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<char*>& tokens, const char* name, int
|
|||
}
|
||||
|
||||
const auto bytes = static_cast<unsigned>(file.Size());
|
||||
std::unique_ptr<char, decltype(&std::free)> buffer(static_cast<char*>(std::malloc(static_cast<std::size_t>(bytes) + 1)), &std::free);
|
||||
|
||||
if (!buffer) {
|
||||
file.Close();
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
std::unique_ptr<char[]> buffer(new char[static_cast<std::size_t>(bytes) + 1]);
|
||||
|
||||
std::memcpy(buffer.get(), file.Data(), bytes);
|
||||
buffer.get()[bytes] = '\0';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue