Skip to content

Commit 29d0a2e

Browse files
authored
Fix memory leak in INIClass, memory corruption in HashTableClass (#799)
1 parent bf3b5e9 commit 29d0a2e

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

src/game/common/system/memdynalloc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void DynamicMemoryAllocator::Init(MemoryPoolFactory *factory, int subpools, Pool
6969

7070
DynamicMemoryAllocator::~DynamicMemoryAllocator()
7171
{
72-
captainslog_dbgassert(m_usedBlocksInDma, "Destroying none empty DMA.");
72+
captainslog_dbgassert(m_usedBlocksInDma == 0, "Destroying none empty DMA.");
7373

7474
for (int i = 0; i < m_poolCount; ++i) {
7575
m_factory->Destroy_Memory_Pool(m_pools[i]);

src/w3d/lib/hash.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ HashTableClass::HashTableClass(int size)
3434
HashTableClass::~HashTableClass()
3535
{
3636
if (m_hashTable) {
37-
delete (m_hashTable);
37+
delete[](m_hashTable);
3838
}
3939
m_hashTable = nullptr;
4040
}

src/w3d/lib/iniclass.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ INIClass::INIClass(FileClass &file) : m_fileName(nullptr)
9999
INIClass::~INIClass()
100100
{
101101
Clear();
102+
Shutdown();
103+
}
104+
105+
void INIClass::Shutdown()
106+
{
107+
delete m_sectionList;
108+
delete m_sectionIndex;
109+
delete[] m_fileName;
102110
}
103111

104112
void INIClass::Initialize()

src/w3d/lib/iniclass.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class INIClass
137137
virtual ~INIClass();
138138

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

0 commit comments

Comments
 (0)