Core/SAI: Fix crash in SmartScript
Fix crash in SmartScript storing WorldObject* instead of guid as targets in SmartScript::mTargetStorage , used by SMART_TARGET_STORED target type , SMART_ESCORT_TARGETS and other escort related code. Fixes #11228 , #10157 . Valgrind log: Invalid read of size 4 at : Object::GetTypeId() const (Object.h:140) by : SmartScript::IsPlayer(WorldObject*) (SmartScript.h:73) by : SmartScript::ProcessAction(SmartScriptHolder&, Unit*, unsigned int, unsigned int, bool, SpellInfo const*, GameObject*) (SmartScript.cpp:330) by : SmartScript::ProcessEvent(SmartScriptHolder&, Unit*, unsigned int, unsigned int, bool, SpellInfo const*, GameObject*) (SmartScript.cpp:2662) by : SmartScript::ProcessAction(SmartScriptHolder&, Unit*, unsigned int, unsigned int, bool, SpellInfo const*, GameObject*) (SmartScript.cpp:2226) by : SmartScript::ProcessTimedAction(SmartScriptHolder&, unsigned int const&, unsigned int const&, Unit*, unsigned int, unsigned int, bool, SpellInfo const*, GameObject*) (SmartScript.cpp:2238) by : SmartScript::ProcessEvent(SmartScriptHolder&, Unit*, unsigned int, unsigned int, bool, SpellInfo const*, GameObject*) (SmartScript.cpp:2685) by : SmartScript::UpdateTimer(SmartScriptHolder&, unsigned int) (SmartScript.cpp:3198) by : SmartScript::OnUpdate(unsigned int) (SmartScript.cpp:3244) by : SmartAI::UpdateAI(unsigned int) (SmartAI.cpp:331) by : Creature::Update(unsigned int) (Creature.cpp:544) by : void Trinity::ObjectUpdater::Visit<Creature>(GridRefManager<Creature>&) (GridNotifiers.cpp:340)
This commit is contained in:
1 parent
de1d75af70
commit
b8625f41bd
3 files changed
+57
-5
No files matched your search
@@ -1321,7 +1321,56 @@ struct SmartScriptHolder
|
||||
typedef UNORDERED_MAP<uint32, WayPoint*> WPPath;
|
||||
|
||||
typedef std::list<WorldObject*> ObjectList;
|
||||
typedef UNORDERED_MAP<uint32, ObjectList*> ObjectListMap;
|
||||
typedef std::list<uint64> GuidList;
|
||||
class ObjectGuidList
|
||||
{
|
||||
ObjectList* m_objectList;
|
||||
GuidList* m_guidList;
|
||||
WorldObject* m_baseObject;
|
||||
|
||||
public:
|
||||
ObjectGuidList(ObjectList* objectList, WorldObject* baseObject)
|
||||
{
|
||||
ASSERT(objectList != NULL);
|
||||
ASSERT(baseObject != NULL);
|
||||
m_objectList = objectList;
|
||||
m_baseObject = baseObject;
|
||||
m_guidList = new GuidList();
|
||||
|
||||
for (ObjectList::iterator itr = objectList->begin(); itr != objectList->end(); ++itr)
|
||||
{
|
||||
m_guidList->push_back((*itr)->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
ObjectList* GetObjectList()
|
||||
{
|
||||
//sanitize list using m_guidList
|
||||
m_objectList->clear();
|
||||
|
||||
for (GuidList::iterator itr = m_guidList->begin(); itr != m_guidList->end(); ++itr)
|
||||
{
|
||||
if (WorldObject* obj = ObjectAccessor::GetWorldObject(*m_baseObject, *itr))
|
||||
m_objectList->push_back(obj);
|
||||
else
|
||||
TC_LOG_DEBUG("scripts.ai", "SmartScript::mTargetStorage stores a guid to an invalid object: " UI64FMTD, *itr);
|
||||
}
|
||||
|
||||
return m_objectList;
|
||||
}
|
||||
|
||||
bool Equals(ObjectList* objectList)
|
||||
{
|
||||
return m_objectList == objectList;
|
||||
}
|
||||
|
||||
~ObjectGuidList()
|
||||
{
|
||||
delete m_objectList;
|
||||
delete m_guidList;
|
||||
}
|
||||
};
|
||||
typedef UNORDERED_MAP<uint32, ObjectGuidList*> ObjectListMap;
|
||||
|
||||
class SmartWaypointMgr
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user