Fixed unhook event crash (bug 3814, r=dvander)

This commit is contained in:
Matt Woodrow 2009-05-11 11:32:59 +12:00
parent 211c5dcfcd
commit bd97bdd378

View File

@ -194,7 +194,7 @@ EventHookError EventManager::HookEvent(const char *name, IPluginFunction *pFunct
} }
/* Cache the name for post hooks */ /* Cache the name for post hooks */
pHook->name = strdup(name); pHook->name = sm_strdup(name);
/* Increase reference count */ /* Increase reference count */
pHook->refCount++; pHook->refCount++;
@ -300,7 +300,7 @@ EventHookError EventManager::UnhookEvent(const char *name, IPluginFunction *pFun
sm_trie_delete(m_EventHooks, name); sm_trie_delete(m_EventHooks, name);
/* Free the cached name */ /* Free the cached name */
free(pHook->name); delete pHook->name;
/* And finally free structure memory */ /* And finally free structure memory */
delete pHook; delete pHook;
@ -472,7 +472,7 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
assert(pHook->pPostHook == NULL); assert(pHook->pPostHook == NULL);
assert(pHook->pPreHook == NULL); assert(pHook->pPreHook == NULL);
sm_trie_delete(m_EventHooks, pHook->name); sm_trie_delete(m_EventHooks, pHook->name);
free(pHook->name); delete pHook->name;
delete pHook; delete pHook;
} }
} }