From 97df408d510015d8fb7f7faafc43ac1f7a8aaf3b Mon Sep 17 00:00:00 2001 From: Vincent Herbet Date: Tue, 3 Oct 2017 20:43:30 +0200 Subject: [PATCH] Fix a crash on the same newmenu overlapping (#462) --- amxmodx/newmenus.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/amxmodx/newmenus.cpp b/amxmodx/newmenus.cpp index 9b16b235..478be49e 100755 --- a/amxmodx/newmenus.cpp +++ b/amxmodx/newmenus.cpp @@ -809,18 +809,25 @@ static cell AMX_NATIVE_CALL menu_items(AMX *amx, cell *params) //page indices start at 0! static cell AMX_NATIVE_CALL menu_display(AMX *amx, cell *params) { - GETMENU(params[2]); - + auto handle = params[2]; + GETMENU(handle); + int player = params[1]; int page = params[3]; CPlayer* pPlayer = GET_PLAYER_POINTER_I(player); - + if (!CloseNewMenus(pPlayer)) { LogError(amx, AMX_ERR_NATIVE, "Plugin called menu_display when item=MENU_EXIT"); return 0; } + if (!g_NewMenus[handle]) + { + LogError(amx, AMX_ERR_NATIVE, "Invalid menu id %d (was previously destroyed).", handle); + return 0; + } + int time = -1; if (params[0] / sizeof(cell) >= 4) time = params[4];