From f34cc0b8e3517a278dbbecdad433ecf907df96cf Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 17 Aug 2023 08:46:38 +0200 Subject: [PATCH] LibWeb: Null check fonts after parsing them in CRC2D.font assignment Fixes an issue where setting CRC2D.font to an unparseable value would assert due to a null dereference. --- Tests/LibWeb/Text/expected/canvas/basic.txt | 2 ++ Tests/LibWeb/Text/input/canvas/basic.html | 11 +++++++++++ .../LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/canvas/basic.txt create mode 100644 Tests/LibWeb/Text/input/canvas/basic.html diff --git a/Tests/LibWeb/Text/expected/canvas/basic.txt b/Tests/LibWeb/Text/expected/canvas/basic.txt new file mode 100644 index 0000000000..07cc20e4ac --- /dev/null +++ b/Tests/LibWeb/Text/expected/canvas/basic.txt @@ -0,0 +1,2 @@ +normal normal 20px SerenitySans +normal normal 20px SerenitySans diff --git a/Tests/LibWeb/Text/input/canvas/basic.html b/Tests/LibWeb/Text/input/canvas/basic.html new file mode 100644 index 0000000000..8eeb3fe0c1 --- /dev/null +++ b/Tests/LibWeb/Text/input/canvas/basic.html @@ -0,0 +1,11 @@ + + diff --git a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h index b6f662cd7b..36836292bc 100644 --- a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h +++ b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h @@ -45,7 +45,7 @@ public: auto font_style_value_result = parse_css_value(parsing_context, font, CSS::PropertyID::Font); // If the new value is syntactically incorrect (including using property-independent style sheet syntax like 'inherit' or 'initial'), then it must be ignored, without assigning a new font value. - if (font_style_value_result.is_error()) { + if (font_style_value_result.is_error() || !font_style_value_result.value()) { return; } my_drawing_state().font_style_value = font_style_value_result.value();