From 9f58a15e284af3e9deb4d38903427a32d8cd78ab Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 Apr 2012 09:16:19 +0000 Subject: [PATCH] - check for overflows when giving inventory items. SVN r3515 (trunk) --- src/g_shared/a_pickups.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index 478c64524..ceb97fc3d 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -86,7 +86,14 @@ bool AAmmo::HandlePickup (AInventory *item) } int oldamount = Amount; - Amount += receiving; + if (Amount > 0 && Amount + receiving < 0) + { + Amount = 0x7fffffff; + } + else + { + Amount += receiving; + } if (Amount > MaxAmount && !sv_unlimited_pickup) { Amount = MaxAmount; @@ -538,7 +545,15 @@ bool AInventory::HandlePickup (AInventory *item) { if (Amount < MaxAmount || sv_unlimited_pickup) { - Amount += item->Amount; + if (Amount > 0 && Amount + item->Amount < 0) + { + Amount = 0x7fffffff; + } + else + { + Amount += item->Amount; + } + if (Amount > MaxAmount && !sv_unlimited_pickup) { Amount = MaxAmount;