From d1ecb3265298bcede93719fcdb0117ffe9b31fcd Mon Sep 17 00:00:00 2001 From: KimLS Date: Fri, 4 Apr 2014 12:27:18 -0700 Subject: [PATCH] Fix for crash in EntityList::MobInZone(Mob *who) when a dangling pointer is passed to the function. Which used to work without crashing but was changed at some point which can be triggered by quests in some situations. --- zone/entity.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index f5533cb84..ed5ee33f0 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -3415,9 +3415,14 @@ void EntityList::ReloadAllClientsTaskState(int TaskID) bool EntityList::IsMobInZone(Mob *who) { - auto it = mob_list.find(who->GetID()); - if (it != mob_list.end()) - return who == it->second; + //We don't use mob_list.find(who) because this code needs to be able to handle dangling pointers for the quest code. + auto it = mob_list.begin(); + while(it != mob_list.end()) { + if(it->second == who) { + return true; + } + ++it; + } return false; }