1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:58:11 +00:00

LibWeb: Ensure parent is not null in DOMTreeModel::index_for_node()

Fix a crash when inspecting empty pages or areas of the page with no
elements.
This commit is contained in:
Dana Burkart 2021-10-15 13:51:43 -07:00 committed by Linus Groh
parent fd8c94c094
commit 4f9aefadef

View file

@ -172,6 +172,8 @@ GUI::ModelIndex DOMTreeModel::index_for_node(i32 node_id) const
auto node = m_node_id_to_dom_node_map.get(node_id).value_or(nullptr);
if (node) {
auto* parent = get_parent(*node);
if (!parent)
return {};
auto parent_children = get_children(*parent);
for (size_t i = 0; i < parent_children->size(); i++) {
if (&parent_children->at(i).as_object() == node) {