[Crash] Check mob pointer before trying to remove it (#4230)

This commit is contained in:
Chris Miles 2024-04-01 17:09:57 -05:00 committed by GitHub
parent e64f03fcc0
commit 3a5381d38a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2675,6 +2675,10 @@ void EntityList::RemoveAllMobs()
{
auto it = mob_list.begin();
while (it != mob_list.end()) {
if (!it->second) {
++it;
continue;
}
safe_delete(it->second);
free_ids.push(it->first);
it = mob_list.erase(it);
@ -2812,6 +2816,9 @@ bool EntityList::RemoveMob(uint16 delete_id)
auto it = mob_list.find(delete_id);
if (it != mob_list.end()) {
if (!it->second) {
return false;
}
if (npc_list.count(delete_id)) {
entity_list.RemoveNPC(delete_id);
}