summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstelar7 <dudedbz@gmail.com>2023-05-27 22:56:07 +0200
committerAndreas Kling <kling@serenityos.org>2023-05-31 05:56:46 +0200
commite23d31ae8392122fc13c7df2c48a62403e5e8441 (patch)
tree8dca6a4cd9cb4b23885222bc28478d3dc1ec9b60
parent5cdeb994b29c6c3befbeb00e7a0b14c0d91b0056 (diff)
downloadserenity-e23d31ae8392122fc13c7df2c48a62403e5e8441.zip
LibWeb: Lazy evaluate optional to avoid crash
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index 8c75b3b8d5..902babeda0 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -7492,8 +7492,10 @@ ErrorOr<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readonl
break;
case CalculatedStyleValue::ResolvedType::Integer:
case CalculatedStyleValue::ResolvedType::Number:
- if (property_accepts_numeric)
- return PropertyAndValue { property_accepting_integer.value_or(property_accepting_number.value()), calculated };
+ if (property_accepts_numeric) {
+ auto property_or_resolved = property_accepting_integer.value_or_lazy_evaluated([property_accepting_number]() { return property_accepting_number.value(); });
+ return PropertyAndValue { property_or_resolved, calculated };
+ }
break;
case CalculatedStyleValue::ResolvedType::Length:
if (auto property = any_property_accepts_type(property_ids, ValueType::Length); property.has_value())