Skip to content

Commit

Permalink
Fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNormalnij committed Jun 12, 2024
1 parent ba5b3e5 commit e821f4c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Client/game_sa/CBuildingRemovalSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ void CBuildingRemovalSA::RemoveWorldBuildingFromLists(CEntitySAInterface* pInter
// is the pointer the same as the one being deleted
if ((DWORD)pFound->m_pInterface == (DWORD)pInterface)
{
delete pFound;
// remove it from the data buildings list so we don't try and remove or add it again.
m_pDataBuildings->erase(iterator++);
}
Expand All @@ -672,9 +673,9 @@ void CBuildingRemovalSA::RemoveWorldBuildingFromLists(CEntitySAInterface* pInter
}
{
// Init some variables
std::pair<std::multimap<unsigned short, sBuildingRemovalItem*>::iterator, std::multimap<unsigned short, sBuildingRemovalItem*>::iterator>
std::pair<std::multimap<uint16_t, sBuildingRemovalItem*>::iterator, std::multimap<uint16_t, sBuildingRemovalItem*>::iterator>
binaryIterators = m_pBinaryBuildings->equal_range(pInterface->m_nModelIndex);
std::multimap<unsigned short, sBuildingRemovalItem*>::const_iterator iteratorBinary = binaryIterators.first;
std::multimap<uint16_t, sBuildingRemovalItem*>::const_iterator iteratorBinary = binaryIterators.first;
for (; iteratorBinary != binaryIterators.second;)
{
sBuildingRemovalItem* pFound = (*iteratorBinary).second;
Expand All @@ -683,6 +684,7 @@ void CBuildingRemovalSA::RemoveWorldBuildingFromLists(CEntitySAInterface* pInter
// is the pointer the same as the one being deleted
if ((DWORD)pFound->m_pInterface == (DWORD)pInterface)
{
delete pFound;
// remove it from the data buildings list so we don't try and remove or add it again.
m_pBinaryBuildings->erase(iteratorBinary++);
}
Expand Down

0 comments on commit e821f4c

Please sign in to comment.