From ed1a7aee4315ffbc97286124971c43ab582de752 Mon Sep 17 00:00:00 2001 From: Mathis Wiehl Date: Sat, 18 Mar 2023 21:01:25 +0100 Subject: [PATCH] LibWeb: Don't deref HTMLInputElement parent if its null Don't crash in case the elements parent is null. --- Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index a23519abe8..62a2101d40 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -88,9 +88,11 @@ void HTMLInputElement::set_checked(bool checked, ChangeSource change_source) // This element's :checked pseudo-class could be used in a sibling's sibling-selector, // so we need to invalidate the style of all siblings. - parent()->for_each_child([&](auto& child) { - child.invalidate_style(); - }); + if (parent()) { + parent()->for_each_child([&](auto& child) { + child.invalidate_style(); + }); + } } void HTMLInputElement::set_checked_binding(bool checked)