diff options
author | /dev/humancontroller <devhc@example.com> | 2014-07-13 15:46:23 +0200 |
---|---|---|
committer | /dev/humancontroller <devhc@example.com> | 2017-03-09 13:51:09 +0100 |
commit | 28d7fce50edbebc32d987b1d9c788b47051eb43e (patch) | |
tree | 734f65e86676b98067cd0dc82b263fb4340bff9f /src/cgame | |
parent | 98428e912d7f9385c8dab17231c22f8e2c3d288b (diff) |
add bounds checking to the weapon number in CG_AddPlayerWeapon()
Diffstat (limited to 'src/cgame')
-rw-r--r-- | src/cgame/cg_weapons.c | 7 |
1 files changed, 7 insertions, 0 deletions
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; |