summaryrefslogtreecommitdiff
path: root/src/Fl_Menu.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2025-11-30 00:40:11 +0100
committerMatthias Melcher <github@matthiasm.com>2025-11-30 00:40:11 +0100
commit89c116bf5f418e2b9821e4c83052735763a6bf20 (patch)
treeeee87901f6cb17e6e26aee2914bde05219839dcb /src/Fl_Menu.cxx
parent110857a6fc73c717ef918193f8ef4cfc70044885 (diff)
Fix menu crash dereferencing nullptr (#1335)
Diffstat (limited to 'src/Fl_Menu.cxx')
-rw-r--r--src/Fl_Menu.cxx6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx
index 72be0befe..36c191e56 100644
--- a/src/Fl_Menu.cxx
+++ b/src/Fl_Menu.cxx
@@ -1499,12 +1499,16 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown(
pp.menubar_button_helper = nullptr;
}
initial_item = 0; // stop the startup code
+ if (pp.current_menu_ix < 0 || pp.current_menu_ix >= pp.num_menus) {
+ initial_item = 0; // turn off startup code
+ continue;
+ }
pp.menu_window[pp.current_menu_ix]->autoscroll(pp.current_item_ix);
STARTUP:
Menu_Window& cw = *pp.menu_window[pp.current_menu_ix];
const Fl_Menu_Item* m = pp.current_item;
- if (!m->selectable()) { // pointing at inactive item
+ if (!m || !m->selectable()) { // pointing at inactive item
cw.set_selected(-1);
initial_item = 0; // turn off startup code
continue;