mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-28 15:55:37 +03:00
Add player validation for menu_display (#671)
Invalid player triggered crash because get/set_pdata is unsafe
This commit is contained in:
parent
7515038e07
commit
6dba7c4f17
@ -809,8 +809,21 @@ static cell AMX_NATIVE_CALL menu_display(AMX *amx, cell *params)
|
|||||||
|
|
||||||
int player = params[1];
|
int player = params[1];
|
||||||
int page = params[3];
|
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);
|
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))
|
if (!CloseNewMenus(pPlayer))
|
||||||
{
|
{
|
||||||
LogError(amx, AMX_ERR_NATIVE, "Plugin called menu_display when item=MENU_EXIT");
|
LogError(amx, AMX_ERR_NATIVE, "Plugin called menu_display when item=MENU_EXIT");
|
||||||
|
Loading…
Reference in New Issue
Block a user