From 9ac54e5fb28782136cbdebe6ec050ccdc64d70c3 Mon Sep 17 00:00:00 2001 From: Scott Ehlert <ds@alliedmods.net> Date: Fri, 6 Jun 2008 04:55:27 +0000 Subject: [PATCH] Fixed rare crash in event manager when a null IGameEvent pointer was passed to the IGameEventManager2::FireEvent() hooks --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402245 --- core/EventManager.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/EventManager.cpp b/core/EventManager.cpp index 76ad2478..d98514f4 100644 --- a/core/EventManager.cpp +++ b/core/EventManager.cpp @@ -359,6 +359,12 @@ bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast) IChangeableForward *pForward; const char *name; cell_t res = Pl_Continue; + + /* The engine accepts NULL without crashing, so to prevent a crash in SM we ignore these */ + if (!pEvent) + { + RETURN_META_VALUE(MRES_IGNORED, false); + } /* Get the event name, we're going to need this for passing to post hooks */ name = pEvent->GetName(); @@ -407,6 +413,12 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast) const char *name; Handle_t hndl = 0; + /* The engine accepts NULL without crashing, so to prevent a crash in SM we ignore these */ + if (!pEvent) + { + RETURN_META_VALUE(MRES_IGNORED, false); + } + name = m_EventNames.front(); if (sm_trie_retrieve(m_EventHooks, name, reinterpret_cast<void **>(&pHook)))