LibWeb/CSS: Check for NULL block statement when parsing font-face rule

This prevents font-face rules without a block statement from crashing
LibWeb during CSS parsing.

The issue was discovered by Lubrsi during CSS parser fuzzing. :)
Fixes #14141.
This commit is contained in:
CodeforEvolution 2022-06-23 12:37:21 -05:00 committed by Linus Groh
parent f807fe6f6c
commit a02ee29af9

View file

@ -2361,7 +2361,7 @@ RefPtr<CSSRule> Parser::convert_to_rule(NonnullRefPtr<Rule> rule)
if (has_ignored_vendor_prefix(rule->at_rule_name())) {
return {};
} else if (rule->at_rule_name().equals_ignoring_case("font-face"sv)) {
if (rule->prelude().is_empty() || !rule->block()->is_curly()) {
if (rule->prelude().is_empty() || !rule->block() || !rule->block()->is_curly()) {
dbgln_if(CSS_PARSER_DEBUG, "@font-face rule is malformed.");
return {};
}