From 28d7fce50edbebc32d987b1d9c788b47051eb43e Mon Sep 17 00:00:00 2001 From: /dev/humancontroller Date: Sun, 13 Jul 2014 15:46:23 +0200 Subject: add bounds checking to the weapon number in CG_AddPlayerWeapon() --- src/cgame/cg_weapons.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/cgame') diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index 27aa04e8..75ea4d38 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -993,6 +993,13 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent weaponNum = cent->currentState.weapon; weaponMode = cent->currentState.generic1; + if( weaponNum <= WP_NONE || weaponNum >= WP_NUM_WEAPONS ) + { + Com_Printf( S_COLOR_YELLOW "WARNING: CG_AddPlayerWeapon: weapon " + "number %i is out of bounds", weaponNum ); + return; + } + if( weaponMode <= WPM_NONE || weaponMode >= WPM_NUM_WEAPONMODES ) weaponMode = WPM_PRIMARY; -- cgit