From ca0890ce16477542b30fa0444c95afa8a2da6275 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 9 Apr 2025 11:33:18 +0100 Subject: [PATCH] LibWeb/CSS: Only try to fetch `@import`s with a parent style sheet When `CSSRuleList::remove_a_css_rule()` is called, the removed rule has its parent style sheet set to null. We shouldn't try to fetch an import in this case. --- Libraries/LibWeb/CSS/CSSImportRule.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Libraries/LibWeb/CSS/CSSImportRule.cpp b/Libraries/LibWeb/CSS/CSSImportRule.cpp index adac6310417..e2610237cb3 100644 --- a/Libraries/LibWeb/CSS/CSSImportRule.cpp +++ b/Libraries/LibWeb/CSS/CSSImportRule.cpp @@ -56,7 +56,10 @@ void CSSImportRule::set_parent_style_sheet(CSSStyleSheet* parent_style_sheet) // Crude detection of whether we're already fetching. if (m_style_sheet || m_document_load_event_delayer.has_value()) return; - fetch(); + + // Only try to fetch if we now have a parent + if (parent_style_sheet) + fetch(); } // https://www.w3.org/TR/cssom/#serialize-a-css-rule