Merge pull request #203 from Arkshine/fix/crash-on-shutdown

Fix crash by freeing memory the right way
This commit is contained in:
Vincent Herbet 2015-02-12 14:46:53 +01:00
commit 7452317c10

View File

@ -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();