LibWeb: Fix OBOE in bounds check of ResolvedCSSStyleDeclaration#item

Without this, it would return "(invalid CSS::PropertyID)" when
requesting item(decl.length).

(cherry picked from commit 5aacb053a3fa0cf0e2a825c63dd3a4ebd916eda4)
This commit is contained in:
Luke Wilde
2024-11-14 15:37:48 +00:00
committed by Nico Weber
parent 9399d1d949
commit 8ff9aa177f
3 changed files with 10 additions and 1 deletions

View File

@@ -76,7 +76,7 @@ String ResolvedCSSStyleDeclaration::item(size_t index) const
{
// The item(index) method must return the property name of the CSS declaration at position index.
// FIXME: Return custom properties if index > last_longhand_property_id.
if (index > length())
if (index >= length())
return {};
auto property_id = static_cast<PropertyID>(index + to_underlying(first_longhand_property_id));
return string_from_property_id(property_id).to_string();