Prevent integer underflow in item removal

Previously, the only check that the user wasn't trashing more items than they had was clientsided, and this could be bypassed by contacting the server to remove items via a console or the like, and then trashing them before the server could respond, resulting in the count for the items being less than iStackCount. This check prevents that underflow.
This commit is contained in:
NinjaOfLU
2022-04-13 01:58:00 +01:00
committed by GitHub
parent e92cdc4f14
commit 59ec28a5a4

View File

@@ -5441,7 +5441,7 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream* inStream, En
}
}
item->SetCount(item->GetCount() - iStackCount, true);
item->SetCount(item->GetCount() - std::min<uint32_t>(item->GetCount(), iStackCount), true);
EntityManager::Instance()->SerializeEntity(entity);
auto* missionComponent = entity->GetComponent<MissionComponent>();