Fix potential OOB memory access if the player's curr_weapon member is set out of range from CON

git-svn-id: https://svn.eduke32.com/eduke32@7485 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-04-06 06:38:14 +00:00 committed by Christoph Oelckers
parent 0edbd45145
commit 5ac5a2ad3c
1 changed files with 3 additions and 4 deletions

View File

@ -3458,12 +3458,11 @@ void P_SelectNextInvItem(DukePlayer_t *pPlayer)
void P_CheckWeapon(DukePlayer_t *pPlayer)
{
int playerNum;
int weaponNum;
if (pPlayer->reloading)
if (pPlayer->reloading || (unsigned)pPlayer->curr_weapon >= MAX_WEAPONS)
return;
int playerNum, weaponNum;
if (pPlayer->wantweaponfire >= 0)
{
weaponNum = pPlayer->wantweaponfire;