From bcc9ea509b0ff8439005e210fdfe5416f331fe10 Mon Sep 17 00:00:00 2001 From: Gingeh <39150378+Gingeh@users.noreply.github.com> Date: Fri, 10 Jan 2025 13:19:34 +1100 Subject: [PATCH] LibWeb: Check for missing node or invalid query in obtain_theme_color --- Libraries/LibWeb/DOM/Document.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index 37984d52c55d..4315dbb252d2 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -1490,7 +1490,7 @@ void Document::obtain_theme_color() auto media = element.attribute(HTML::AttributeNames::media); if (media.has_value()) { auto query = parse_media_query(context, media.value()); - if (window() && !query->evaluate(*window())) + if (query.is_null() || (window() && !query->evaluate(*window()))) return TraversalDecision::Continue; } @@ -1503,7 +1503,7 @@ void Document::obtain_theme_color() // 4. If color is not failure, then return color. if (!css_value.is_null() && css_value->is_color()) { Optional root_node; - if (html_element()) + if (html_element() && html_element()->layout_node()) root_node = *html_element()->layout_node(); theme_color = css_value->to_color(root_node);