Fix buffer overflow

This commit is contained in:
asasas9500 2020-01-12 12:58:50 -03:00
parent 29ec96ec39
commit 1cb86192bb

View file

@ -184,17 +184,16 @@ int DrawAllPickups()
} }
int pickupIndex = CurrentPickup; int pickupIndex = CurrentPickup;
int i = 0; int i;
do for (i = 0; i < NUM_PICKUPS; ++i)
{ {
if (Pickups[pickupIndex].life > 0) if (Pickups[pickupIndex].life > 0)
break; break;
pickupIndex = (pickupIndex + 1) & 7; pickupIndex = pickupIndex + 1 & NUM_PICKUPS - 1;
i++; }
} while (i < 8);
CurrentPickup = pickupIndex; CurrentPickup = pickupIndex;
if (i != 8) if (i != NUM_PICKUPS)
return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber); return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber);
CurrentPickup = 0; CurrentPickup = 0;
@ -223,7 +222,7 @@ void AddDisplayPickup(short objectNumber)
void InitialisePickupDisplay() void InitialisePickupDisplay()
{ {
for (int i = 0; i < 8; i++) for (int i = 0; i < NUM_PICKUPS; i++)
{ {
DISPLAY_PICKUP* pickup = &Pickups[i]; DISPLAY_PICKUP* pickup = &Pickups[i];
pickup->life = -1; pickup->life = -1;