From 22e0b732db892a4ab382ed0ed62ec8da261d69bd Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Tue, 3 Jun 2025 19:06:56 +0200 Subject: [PATCH] LibJS: Add missing update for holes count in IndexedPropertyStorage This one is required to cover the case when new empty elements are introduced by assigning to element with index > length, like: ```js var x = []; x[0] = 1; x[2] = 2; ``` --- Libraries/LibJS/Runtime/IndexedProperties.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Libraries/LibJS/Runtime/IndexedProperties.cpp b/Libraries/LibJS/Runtime/IndexedProperties.cpp index f630de2cf43..40489b14901 100644 --- a/Libraries/LibJS/Runtime/IndexedProperties.cpp +++ b/Libraries/LibJS/Runtime/IndexedProperties.cpp @@ -48,6 +48,7 @@ void SimpleIndexedPropertyStorage::put(u32 index, Value value, PropertyAttribute VERIFY(attributes == default_attributes); if (index >= m_array_size) { + m_number_of_empty_elements += index - m_array_size; m_array_size = index + 1; grow_storage_if_needed(); } else {