Fix potential leak memory for CRenderFxManager, CPointBaseCommand

CUtlVector::RemoveAll() doesn't free allocated memory
This commit is contained in:
s1lent 2019-08-13 22:52:00 +07:00
parent 0bd5f7a0bb
commit 7420ba158a
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
3 changed files with 14 additions and 4 deletions

View File

@ -150,5 +150,5 @@ void CPointBaseCommand::OnDestroy()
} }
} }
m_vecCommands.RemoveAll(); m_vecCommands.Purge();
} }

View File

@ -373,7 +373,7 @@ void CRenderFxManager::Spawn()
void CRenderFxManager::OnDestroy() void CRenderFxManager::OnDestroy()
{ {
m_RenderGroups.RemoveAll(); m_RenderGroups.Purge();
} }
void CRenderFxManager::Restart() void CRenderFxManager::Restart()
@ -1837,7 +1837,7 @@ bool CBombTarget::IsPlayerInBombSite(CBasePlayer *pPlayer)
{ {
const Vector &absmin = pPlayer->pev->absmin; const Vector &absmin = pPlayer->pev->absmin;
const Vector &absmax = pPlayer->pev->absmax; const Vector &absmax = pPlayer->pev->absmax;
// Ensure that player's body is inside func_bomb_target's X,Y axes. // Ensure that player's body is inside func_bomb_target's X,Y axes.
if (pev->absmin.x > absmin.x || pev->absmin.y > absmin.y) if (pev->absmin.x > absmin.x || pev->absmin.y > absmin.y)
{ {
@ -1847,7 +1847,7 @@ bool CBombTarget::IsPlayerInBombSite(CBasePlayer *pPlayer)
{ {
return false; return false;
} }
return true; return true;
} }

View File

@ -148,6 +148,7 @@ public:
void RemoveAt(I i); void RemoveAt(I i);
bool Remove(T const &remove); bool Remove(T const &remove);
void RemoveAll(); void RemoveAll();
void Purge();
// Allocation, deletion // Allocation, deletion
void FreeNode(I i); void FreeNode(I i);
@ -848,6 +849,15 @@ void CUtlRBTree<T, I, L, M>::RemoveAll()
m_NumElements = 0; m_NumElements = 0;
} }
template <class T, class I, typename L, class M>
void CUtlRBTree<T, I, L, M>::Purge()
{
RemoveAll();
m_FirstFree = InvalidIndex();
m_TotalElements = 0;
m_Elements.Purge();
}
// Iteration // Iteration
template <class T, class I, typename L, class M> template <class T, class I, typename L, class M>
I CUtlRBTree<T, I, L, M>::FirstInorder() const I CUtlRBTree<T, I, L, M>::FirstInorder() const