From ac3f053411c096dea192e9572c7cb3abc32d8b6e Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Fri, 12 Oct 2012 12:59:32 +0100 Subject: menu: Disallow navigation to a disabled entry via *any* key Generalise the fix from commit c823574f53c1 ("menu: Don't highlight disabled entries") as it only handled the case where we navigated to a disabled last entry by pressing Ctrl + N or the DOWN arrow key. Obviously, we can navigate with other keys such as END, PGDN, etc so we need to handle all cases. Reported-by: Ady Signed-off-by: Matt Fleming --- com32/menu/menumain.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c index 7c589797..8573901c 100644 --- a/com32/menu/menumain.c +++ b/com32/menu/menumain.c @@ -806,7 +806,7 @@ static const char *run_menu(void) while (entry < cm->nentries && is_disabled(cm->menu_entries[entry])) entry++; } - if (entry >= cm->nentries) { + if (entry >= cm->nentries - 1) { entry = cm->nentries - 1; while (entry > 0 && is_disabled(cm->menu_entries[entry])) entry--; @@ -958,7 +958,8 @@ static const char *run_menu(void) case KEY_DOWN: case KEY_CTRL('N'): - while (++entry < cm->nentries) { + while (entry < cm->nentries - 1) { + entry++; if (entry >= top + MENU_ROWS) top += MENU_ROWS; if (!is_disabled(cm->menu_entries[entry])) -- cgit v1.2.1