Skip to content

Commit

Permalink
Add player validation for menu_display (#671)
Browse files Browse the repository at this point in the history
Invalid player triggered crash because get/set_pdata is unsafe
  • Loading branch information
voed authored and Arkshine committed Jan 30, 2019
1 parent ba083de commit 5947926
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions amxmodx/newmenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,20 @@ static cell AMX_NATIVE_CALL menu_display(AMX *amx, cell *params)

int player = params[1];
int page = params[3];

if (player < 1 || player > gpGlobals->maxClients)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid player id %d.", player);
return 0;
}

CPlayer* pPlayer = GET_PLAYER_POINTER_I(player);

if (!pPlayer->ingame)
{
LogError(amx, AMX_ERR_NATIVE, "Player %d is not in game.", player);
return 0;
}

if (!CloseNewMenus(pPlayer))
{
Expand Down

0 comments on commit 5947926

Please sign in to comment.