Skip to content

Commit

Permalink
Fix memory leak in INIClass, memory corruption in HashTableClass (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
feliwir authored Nov 16, 2022
1 parent bf3b5e9 commit 29d0a2e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/game/common/system/memdynalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void DynamicMemoryAllocator::Init(MemoryPoolFactory *factory, int subpools, Pool

DynamicMemoryAllocator::~DynamicMemoryAllocator()
{
captainslog_dbgassert(m_usedBlocksInDma, "Destroying none empty DMA.");
captainslog_dbgassert(m_usedBlocksInDma == 0, "Destroying none empty DMA.");

for (int i = 0; i < m_poolCount; ++i) {
m_factory->Destroy_Memory_Pool(m_pools[i]);
Expand Down
2 changes: 1 addition & 1 deletion src/w3d/lib/hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ HashTableClass::HashTableClass(int size)
HashTableClass::~HashTableClass()
{
if (m_hashTable) {
delete (m_hashTable);
delete[](m_hashTable);
}
m_hashTable = nullptr;
}
Expand Down
8 changes: 8 additions & 0 deletions src/w3d/lib/iniclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ INIClass::INIClass(FileClass &file) : m_fileName(nullptr)
INIClass::~INIClass()
{
Clear();
Shutdown();
}

void INIClass::Shutdown()
{
delete m_sectionList;
delete m_sectionIndex;
delete[] m_fileName;
}

void INIClass::Initialize()
Expand Down
1 change: 1 addition & 0 deletions src/w3d/lib/iniclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class INIClass
virtual ~INIClass();

void Initialize();
void Shutdown();
bool Clear(const char *section = nullptr, const char *entry = nullptr);
bool Is_Loaded() const { return m_sectionList->First()->Is_Valid(); }

Expand Down

0 comments on commit 29d0a2e

Please sign in to comment.