Skip to content

Commit

Permalink
fix: use after free in mission progression after removing item from i…
Browse files Browse the repository at this point in the history
…nventory (#1567)

that method is cursed.

no longer has ub when deleting an item from the inventory
  • Loading branch information
EmosewaMC authored May 12, 2024
1 parent 4d1395e commit 9f382ac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dGame/dGameMessages/GameMessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 9f382ac

Please sign in to comment.