From 5ac5a2ad3ca6228be641ad1cb93eb412feee58aa Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 6 Apr 2019 06:38:14 +0000 Subject: [PATCH] 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 --- source/duke3d/src/player.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/duke3d/src/player.cpp b/source/duke3d/src/player.cpp index 1995984d2..adbd766e2 100644 --- a/source/duke3d/src/player.cpp +++ b/source/duke3d/src/player.cpp @@ -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;