LibJS: Only do a single property lookup in internal_get_own_property()

Instead of checking storage_has(), followed by storage_get(), we can do
storage_get() directly and avoid a redundant property lookup.

This exposed a bug in SimpleIndexedPropertyStorage::get() which would
previously succeed for array holes.
This commit is contained in:
Andreas Kling 2021-10-05 15:05:06 +02:00
commit 6108bac606
Notes: sideshowbarker 2024-07-18 03:01:56 +09:00
2 changed files with 4 additions and 3 deletions

View file

@ -26,7 +26,7 @@ bool SimpleIndexedPropertyStorage::has_index(u32 index) const
Optional<ValueAndAttributes> SimpleIndexedPropertyStorage::get(u32 index) const
{
if (index >= m_array_size)
if (!has_index(index))
return {};
return ValueAndAttributes { m_packed_elements[index], default_attributes };
}