fix: use after free in mission progression after removing item from inventory (#1567)

that method is cursed.

no longer has ub when deleting an item from the inventory
This commit is contained in:
David Markowitz 2024-05-12 05:30:03 -07:00 committed by GitHub
parent 4d1395e522
commit 9f382aca42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5354,14 +5354,14 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream& inStream, En
if (eInvType == eInventoryType::MODELS) {
item->DisassembleModel(iStackCount);
}
auto lot = item->GetLot();
item->SetCount(item->GetCount() - iStackCount, true);
Game::entityManager->SerializeEntity(entity);
auto* missionComponent = entity->GetComponent<MissionComponent>();
if (missionComponent != nullptr) {
missionComponent->Progress(eMissionTaskType::GATHER, item->GetLot(), LWOOBJID_EMPTY, "", -iStackCount);
missionComponent->Progress(eMissionTaskType::GATHER, lot, LWOOBJID_EMPTY, "", -iStackCount);
}
}
}