mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-23 03:52:12 -04:00
report (and secure) weaponinfo[] overruns (#1221)
This commit is contained in:
parent
3741b89a0d
commit
a6f4274553
@ -32,7 +32,7 @@
|
||||
// atkstate, i.e. attack/fire/hit frame
|
||||
// flashstate, muzzle flash
|
||||
//
|
||||
weaponinfo_t weaponinfo[NUMWEAPONS] =
|
||||
weaponinfo_t weaponinfo[NUMWEAPONS+1] =
|
||||
{
|
||||
{
|
||||
// fist
|
||||
@ -142,6 +142,9 @@ weaponinfo_t weaponinfo[NUMWEAPONS] =
|
||||
0,
|
||||
WPF_NOFLAG
|
||||
},
|
||||
{
|
||||
0
|
||||
},
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -59,7 +59,7 @@ typedef struct
|
||||
int flags;
|
||||
} weaponinfo_t;
|
||||
|
||||
extern weaponinfo_t weaponinfo[NUMWEAPONS];
|
||||
extern weaponinfo_t weaponinfo[NUMWEAPONS+1];
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "doomstat.h"
|
||||
#include "i_printf.h"
|
||||
#include "r_main.h"
|
||||
#include "p_map.h"
|
||||
#include "p_inter.h"
|
||||
@ -154,6 +155,12 @@ static void P_BringUpWeapon(player_t *player)
|
||||
if (player->pendingweapon == wp_chainsaw)
|
||||
S_StartSound(player->mo, sfx_sawup);
|
||||
|
||||
if (player->pendingweapon >= NUMWEAPONS)
|
||||
{
|
||||
player->pendingweapon = NUMWEAPONS;
|
||||
I_Printf(VB_WARNING, "P_BringUpWeapon: weaponinfo overrun has occurred.");
|
||||
}
|
||||
|
||||
newstate = weaponinfo[player->pendingweapon].upstate;
|
||||
|
||||
player->pendingweapon = wp_nochange;
|
||||
|
Loading…
x
Reference in New Issue
Block a user