From 17e25890be1b0058ba70f13f8a975cb8827329bd Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 7 Dec 2020 19:26:25 +0100 Subject: [PATCH] WindowServer: Don't crash when pressing return after opening menu There isn't always a hovered item, so let's not assume things. --- Services/WindowServer/MenuManager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Services/WindowServer/MenuManager.cpp b/Services/WindowServer/MenuManager.cpp index abe9d0cfc48..71a1934dd56 100644 --- a/Services/WindowServer/MenuManager.cpp +++ b/Services/WindowServer/MenuManager.cpp @@ -181,8 +181,7 @@ void MenuManager::event(Core::Event& event) if (key_event.key() == Key_Return) { auto hovered_item = m_current_menu->hovered_item(); - - if (!hovered_item->is_enabled()) + if (!hovered_item || !hovered_item->is_enabled()) return; if (hovered_item->is_submenu()) m_current_menu->descend_into_submenu_at_hovered_item();