From e64f43c3a754d66c4af54a91678b21d0899432fa Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 3 Oct 2020 19:43:46 +0200 Subject: [PATCH] LibGUI: Fix null pointer dereference in enter/leave event handling If an enter/leave event is delivered to a widget after it is removed from a window, we can't just assume a window is gonna be there. Fixes #3669. --- Libraries/LibGUI/Widget.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Libraries/LibGUI/Widget.cpp b/Libraries/LibGUI/Widget.cpp index 06365103e7..7b090c8815 100644 --- a/Libraries/LibGUI/Widget.cpp +++ b/Libraries/LibGUI/Widget.cpp @@ -342,14 +342,16 @@ void Widget::handle_mousedoubleclick_event(MouseEvent& event) void Widget::handle_enter_event(Core::Event& event) { - window()->update_cursor({}); + if (auto* window = this->window()) + window->update_cursor({}); show_tooltip(); enter_event(event); } void Widget::handle_leave_event(Core::Event& event) { - window()->update_cursor({}); + if (auto* window = this->window()) + window->update_cursor({}); Application::the()->hide_tooltip(); leave_event(event); }