Skip to content

Commit

Permalink
Some pointer safety in threat manager
Browse files Browse the repository at this point in the history
Querying nullptr shouldn't even attempt to return anything meaningful.
Passively helps with crashes when threat manager is used carelessly, getVitctim() case in particular.

(based on cmangos/mangos-wotlk@cfb37f659)

Signed-off-by: Xfurry <xfurry.cmangos@outlook.com>
  • Loading branch information
Warlockbugs authored and xfurry committed Jan 2, 2018
1 parent 1f1a46f commit 0aa57e1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/game/ThreatManager.cpp
Expand Up @@ -224,6 +224,8 @@ void ThreatContainer::clearReferences()
// Return the HostileReference of nullptr, if not found
HostileReference* ThreatContainer::getReferenceByTarget(Unit* pVictim)
{
if (!pVictim)
return nullptr;
HostileReference* result = nullptr;
ObjectGuid guid = pVictim->GetObjectGuid();
for (ThreatList::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i)
Expand Down

0 comments on commit 0aa57e1

Please sign in to comment.