Fix array length check in lastIndexOf (#3789)

When lastIndexOf is executed the array length can change and in
case of fast arrays the length should be re-checked.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
This commit is contained in:
Péter Gál
2020-05-25 16:36:54 +02:00
committed by GitHub
parent 589af6dc90
commit 1774cca47c
2 changed files with 35 additions and 1 deletions
@@ -1775,9 +1775,11 @@ ecma_builtin_array_prototype_object_last_index_of (const ecma_value_t args[], /*
if (ecma_op_object_is_fast_array (obj_p))
{
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
// It is possible that the length changed due to the callback performed above.
uint32_t array_length = ext_obj_p->u.array.length;
if (ext_obj_p->u.array.u.hole_count < ECMA_FAST_ARRAY_HOLE_ONE
&& len != 0)
&& array_length > 0)
{
ecma_value_t *buffer_p = ECMA_GET_NON_NULL_POINTER (ecma_value_t, obj_p->u1.property_list_cp);