mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
[Crash Fix] Fix Possible Crash in HateList::Find (#4027)
# Notes - We were not doing any pointer validation, so we were causing crashes in some cases. - Example: http://spire.akkadius.com/dev/release/22.43.2?id=19163
This commit is contained in:
parent
5b43bf4a5e
commit
9ee16f8bf7
@ -80,15 +80,18 @@ bool HateList::IsEntOnHateList(Mob *mob)
|
||||
return false;
|
||||
}
|
||||
|
||||
struct_HateList *HateList::Find(Mob *in_entity)
|
||||
struct_HateList* HateList::Find(Mob* m)
|
||||
{
|
||||
auto iterator = list.begin();
|
||||
while (iterator != list.end())
|
||||
{
|
||||
if ((*iterator)->entity_on_hatelist == in_entity)
|
||||
return (*iterator);
|
||||
++iterator;
|
||||
if (!m) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (auto* e : list) {
|
||||
if (e->entity_on_hatelist && e->entity_on_hatelist == m) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@ -89,7 +89,7 @@ public:
|
||||
|
||||
|
||||
protected:
|
||||
struct_HateList *Find(Mob *ent);
|
||||
struct_HateList* Find(Mob* m);
|
||||
private:
|
||||
std::list<struct_HateList *> list;
|
||||
Mob *hate_owner;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user