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.
This commit is contained in:
parent
ef6a78518f
commit
f34cc0b8e3
Notes:
sideshowbarker
2024-07-16 22:24:48 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f34cc0b8e3 Pull-request: https://github.com/SerenityOS/serenity/pull/20612
3 changed files with 14 additions and 1 deletions
Tests/LibWeb/Text
Userland/Libraries/LibWeb/HTML/Canvas
2
Tests/LibWeb/Text/expected/canvas/basic.txt
Normal file
2
Tests/LibWeb/Text/expected/canvas/basic.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
normal normal 20px SerenitySans
|
||||
normal normal 20px SerenitySans
|
11
Tests/LibWeb/Text/input/canvas/basic.html
Normal file
11
Tests/LibWeb/Text/input/canvas/basic.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
let canvas = document.createElement("canvas");
|
||||
let context = canvas.getContext("2d");
|
||||
context.font = '20px SerenitySans';
|
||||
println(context.font);
|
||||
context.font = '!!!'; // Invalid value, should be ignored.
|
||||
println(context.font);
|
||||
});
|
||||
</script>
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue