From f87edd4c14b0b72575d0915b3255f2870e99d7ea Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 19 Mar 2022 18:09:22 +0100 Subject: [PATCH] LibWeb: Don't crash when detached document tries to use system palette If the current Document is not attached to a Web::Page for whatever reason, but we're trying to look up a color from the system palette, let's just fail the lookup instead of crashing the process. --- Userland/Libraries/LibWeb/CSS/StyleValue.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index 95326cfc38..49de3850d4 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -1121,7 +1121,9 @@ Color IdentifierStyleValue::to_color(Layout::NodeWithStyle const& node) const if (id() == CSS::ValueID::LibwebLink) return document.link_color(); - VERIFY(document.page()); + if (!document.page()) + return {}; + auto palette = document.page()->palette(); switch (id()) { case CSS::ValueID::LibwebPaletteDesktopBackground: