From 07fb0882bfb19a9322b8edadfe5b3ed5d47525f3 Mon Sep 17 00:00:00 2001 From: Marco Cutecchia Date: Wed, 16 Nov 2022 20:00:49 +0100 Subject: [PATCH] LibWeb: Add null checks before derefencing Bitmaps in ImageStyleValue --- Userland/Libraries/LibWeb/CSS/StyleValue.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index 5d3d73c75d..9fbe190757 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -1720,22 +1720,22 @@ bool ImageStyleValue::equals(StyleValue const& other) const Optional ImageStyleValue::natural_width() const { - if (resource()) - return bitmap(0)->width(); + if (auto* b = bitmap(0); b != nullptr) + return b->width(); return {}; } Optional ImageStyleValue::natural_height() const { - if (resource()) - return bitmap(0)->height(); + if (auto* b = bitmap(0); b != nullptr) + return b->height(); return {}; } void ImageStyleValue::paint(PaintContext& context, Gfx::IntRect const& dest_rect, CSS::ImageRendering image_rendering) const { - if (resource()) - context.painter().draw_scaled_bitmap(dest_rect, *bitmap(m_current_frame_index), bitmap(0)->rect(), 1.0f, to_gfx_scaling_mode(image_rendering)); + if (auto* b = bitmap(m_current_frame_index); b != nullptr) + context.painter().draw_scaled_bitmap(dest_rect, *b, bitmap(0)->rect(), 1.0f, to_gfx_scaling_mode(image_rendering)); } static void serialize_color_stop_list(StringBuilder& builder, auto const& color_stop_list)