diff options
author | Andreas Kling <kling@serenityos.org> | 2023-05-19 15:14:34 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-19 15:41:34 +0200 |
commit | 6f204f8c32ca14ed337a1ff946c637330921e71e (patch) | |
tree | 5b6be9f2520390c609fb0a853a60d8a9b2e06df0 /Userland/Libraries | |
parent | 411b28fc592118a38b0a3aeb95b1fe0a05006aa9 (diff) | |
download | serenity-6f204f8c32ca14ed337a1ff946c637330921e71e.zip |
LibWeb: Fix null dereference on SVG element with bogus fill URL
Fixes a crash seen on YouTube channel pages.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp index d62b2f97c4..3fbd746421 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp @@ -51,11 +51,11 @@ Optional<Gfx::PaintStyle const&> SVGGraphicsElement::fill_paint_style(SVGPaintCo if (!fill.has_value() || !fill->is_url()) return {}; auto& url = fill->as_url(); - auto maybe_gradient = document().get_element_by_id(url.fragment()); - if (is<SVG::SVGGradientElement>(*maybe_gradient)) { - auto& gradient = verify_cast<SVG::SVGGradientElement>(*maybe_gradient); - return gradient.to_gfx_paint_style(paint_context); - } + auto gradient = document().get_element_by_id(url.fragment()); + if (!gradient) + return {}; + if (is<SVG::SVGGradientElement>(*gradient)) + return static_cast<SVG::SVGGradientElement const&>(*gradient).to_gfx_paint_style(paint_context); return {}; } |