mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-07 08:29:58 +00:00
LibJS: Let set_array_like_size() switch to generic storage if necessary
This is already considered in put()/insert()/append_all() but not set_array_like_size(), which crashed the interpreter with an assertion when creating an array with more than SPARSE_ARRAY_THRESHOLD (200) initial elements as the simple storage was being resized beyond its limit. Fixes #3382.
This commit is contained in:
parent
28ff8f3376
commit
ae9d64e544
|
@ -346,6 +346,13 @@ void IndexedProperties::append_all(Object* this_object, const IndexedProperties&
|
|||
}
|
||||
}
|
||||
|
||||
void IndexedProperties::set_array_like_size(size_t new_size)
|
||||
{
|
||||
if (m_storage->is_simple_storage() && new_size > SPARSE_ARRAY_THRESHOLD)
|
||||
switch_to_generic_storage();
|
||||
m_storage->set_array_like_size(new_size);
|
||||
}
|
||||
|
||||
Vector<ValueAndAttributes> IndexedProperties::values_unordered() const
|
||||
{
|
||||
if (m_storage->is_simple_storage()) {
|
||||
|
|
|
@ -162,7 +162,7 @@ public:
|
|||
size_t size() const { return m_storage->size(); }
|
||||
bool is_empty() const { return size() == 0; }
|
||||
size_t array_like_size() const { return m_storage->array_like_size(); }
|
||||
void set_array_like_size(size_t new_size) { m_storage->set_array_like_size(new_size); };
|
||||
void set_array_like_size(size_t);
|
||||
|
||||
Vector<ValueAndAttributes> values_unordered() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue