mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +03:00
Fix crash by freeing memory the right way
This commit is contained in:
parent
c556bf9f68
commit
120e5b94f9
@ -618,19 +618,25 @@ void CvarManager::OnAmxxShutdown()
|
|||||||
{
|
{
|
||||||
// Free everything.
|
// Free everything.
|
||||||
|
|
||||||
for (CvarsList::iterator cvar = m_Cvars.begin(); cvar != m_Cvars.end(); cvar = m_Cvars.erase(cvar))
|
CvarsList::iterator iter = m_Cvars.begin();
|
||||||
|
|
||||||
|
while (iter != m_Cvars.end())
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < (*cvar)->binds.length(); ++i)
|
CvarInfo* cvar = (*iter);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < cvar->binds.length(); ++i)
|
||||||
{
|
{
|
||||||
delete (*cvar)->binds[i];
|
delete cvar->binds[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < (*cvar)->hooks.length(); ++i)
|
for (size_t i = 0; i < cvar->hooks.length(); ++i)
|
||||||
{
|
{
|
||||||
delete (*cvar)->hooks[i];
|
delete cvar->hooks[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
delete (*cvar);
|
iter = m_Cvars.erase(iter);
|
||||||
|
|
||||||
|
delete cvar;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Cache.clear();
|
m_Cache.clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user