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:
parent
fd8c94c094
commit
4f9aefadef
1 changed files with 2 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue