mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 09:09:43 +00:00
LibJS: Don't assume value for index < size in IndexedPropertyIterator
This assumption only works for the m_packed_elements Vector where a missing value at a certain index still returns an empty value, but not for the m_sparse_elements HashMap, which is being used for indices >= 200 - in that case the Optional<ValueAndAttributes> result will not have a value. This fixes a crash in the js REPL where printing an array with a hole at any index >= 200 would crash.
This commit is contained in:
parent
a1029738fd
commit
e07490ce13
Notes:
sideshowbarker
2024-07-19 01:54:28 +09:00
Author: https://github.com/linusg
Commit: e07490ce13
Pull-request: https://github.com/SerenityOS/serenity/pull/3763
1 changed files with 1 additions and 1 deletions
|
@ -262,7 +262,7 @@ bool IndexedPropertyIterator::operator!=(const IndexedPropertyIterator& other) c
|
||||||
ValueAndAttributes IndexedPropertyIterator::value_and_attributes(Object* this_object, bool evaluate_accessors)
|
ValueAndAttributes IndexedPropertyIterator::value_and_attributes(Object* this_object, bool evaluate_accessors)
|
||||||
{
|
{
|
||||||
if (m_index < m_indexed_properties.array_like_size())
|
if (m_index < m_indexed_properties.array_like_size())
|
||||||
return m_indexed_properties.get(this_object, m_index, evaluate_accessors).value();
|
return m_indexed_properties.get(this_object, m_index, evaluate_accessors).value_or({});
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue