From 3ea15c5586e778b8f6c33f45fbb95ce50b2d943c Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Wed, 4 Mar 2020 11:15:54 +0100 Subject: [PATCH] Crash when pressing [ENTER] in a menu when nothing is selected --- radio/src/thirdparty/libopenui/src/menu.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/menu.cpp b/radio/src/thirdparty/libopenui/src/menu.cpp index a76991f28..31fd022ee 100644 --- a/radio/src/thirdparty/libopenui/src/menu.cpp +++ b/radio/src/thirdparty/libopenui/src/menu.cpp @@ -42,8 +42,13 @@ void MenuBody::onEvent(event_t event) select(selectedIndex == 0 ? lines.size() - 1 : selectedIndex - 1); } else if (event == EVT_KEY_BREAK(KEY_ENTER)) { - Window::onEvent(event); // the window above will be closed on event - lines[selectedIndex].onPress(); + if (selectedIndex < 0) { + select(0); + } + else { + Window::onEvent(event); // the window above will be closed on event + lines[selectedIndex].onPress(); + } } else if (event == EVT_KEY_BREAK(KEY_EXIT)) { if (onCancel)