1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-23 18:25:08 +00:00

LibWeb: Fix null dereference in HtmlView::mousedown_event

Running event handlers in response to a mouse event may cause full
layout invalidation, so we can't expect the layout root to be present
right after returning from JS.

Fixes #1629.
This commit is contained in:
Andreas Kling 2020-04-07 10:26:54 +02:00
parent e586dc285a
commit f8d6d61da5

View file

@ -242,7 +242,8 @@ void HtmlView::mousedown_event(GUI::MouseEvent& event)
}
} else {
if (event.button() == GUI::MouseButton::Left) {
layout_root()->selection().set({ result.layout_node, result.index_in_node }, {});
if (layout_root())
layout_root()->selection().set({ result.layout_node, result.index_in_node }, {});
dump_selection("MouseDown");
m_in_mouse_selection = true;
}