mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-22 21:43:35 +00:00
Scripts: Fix possible nullptr access (#1232)
unsure how to reproduce the actual bug, however we can see that with the following crash dump ``` Entity::GetComponent(eReplicaComponentType) const(+0x4) [0x56095665e634] BossSpiderQueenEnemyServer::OnDie(Entity*, Entity*)(+0x28d) [0x560956795d0d] Entity::Kill(Entity*)(+0xf8) [0x5609566637a8] ZoneAgProperty::BaseTimerDone(Entity*, std::string const&)(+0x89b) [0x56095683736b] Entity::Update(float)(+0x2b6) [0x560956662676] EntityManager::UpdateEntities(float)(+0x2e) [0x56095667305e] ``` that the actual crash issue starts at ``` Entity::Kill(Entity*)(+0xf8) [0x5609566637a8] ZoneAgProperty::BaseTimerDone(Entity*, std::string const&) ``` BaseTimerDone calls Kill, and there is only 1 call to Kill in the function which calls Kill no arguments, meaning the killer is a nullptr. This propogates its way to the BossSpiderQueenEnemyServer::OnDie wherein we blindly check the killer pointer without verifying that the pointer is actually valid. This patch simply checks that killer is valid before access to address the hole.
This commit is contained in:
parent
5942182486
commit
23d71340c9
@ -52,7 +52,7 @@ void BossSpiderQueenEnemyServer::OnStartup(Entity* self) {
|
||||
}
|
||||
|
||||
void BossSpiderQueenEnemyServer::OnDie(Entity* self, Entity* killer) {
|
||||
if (Game::zoneManager->GetZoneID().GetMapID() == instanceZoneID) {
|
||||
if (Game::zoneManager->GetZoneID().GetMapID() == instanceZoneID && killer) {
|
||||
auto* missionComponent = killer->GetComponent<MissionComponent>();
|
||||
if (missionComponent == nullptr)
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user