From 3ca013d7f052afba218b72ff730010c51b8b0e2b Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 23 Sep 2007 06:51:44 +0000 Subject: [PATCH] fixed a bug where the TE natives could double-free on exit and crash --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401463 --- extensions/sdktools/tenatives.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/extensions/sdktools/tenatives.cpp b/extensions/sdktools/tenatives.cpp index 3cd8b2d4..c4547805 100644 --- a/extensions/sdktools/tenatives.cpp +++ b/extensions/sdktools/tenatives.cpp @@ -38,6 +38,7 @@ SH_DECL_HOOK5_void(IVEngineServer, PlaybackTempEntity, SH_NOATTRIB, 0, IRecipien CellRecipientFilter g_TERecFilter; TempEntityInfo *g_CurrentTE = NULL; int g_TEPlayers[256]; +bool tenatives_initialized = false; /************************* * * @@ -49,10 +50,16 @@ void TempEntHooks::Initialize() { m_TEHooks = adtfactory->CreateBasicTrie(); plsys->AddPluginsListener(this); + tenatives_initialized = true; } void TempEntHooks::Shutdown() { + if (!tenatives_initialized) + { + return; + } + plsys->RemovePluginsListener(this); List::iterator iter; for (iter=m_HookInfo.begin(); iter!=m_HookInfo.end(); iter++) @@ -65,6 +72,7 @@ void TempEntHooks::Shutdown() _DecRefCounter(); } m_TEHooks->Destroy(); + tenatives_initialized = false; } void TempEntHooks::OnPluginUnloaded(IPlugin *plugin)