mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-26 14:55:36 +03:00
Merge pull request #203 from Arkshine/fix/crash-on-shutdown
Fix crash by freeing memory the right way
This commit is contained in:
commit
7452317c10
@ -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