Add bounds check for copyWithin (#3425)

When inputs are out of bounds, we don't need to do anything in the operation.

Fixes #3408

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi [email protected]
This commit is contained in:
Szilagyi Adam authored and Dániel Bátyai committed 2019-12-06 13:33:41 +01:00
1 parent 99fa823bab
commit e70cfed57a
2 files changed
+23

No files matched your search

@@ -2338,6 +2338,12 @@ ecma_builtin_array_prototype_object_copy_within (const ecma_value_t args[], /**<
}
}
if (target >= len || start >= end || end == 0)
{
ecma_ref_object (obj_p);
return ecma_make_object_value (obj_p);
}
uint32_t count = JERRY_MIN (end - start, len - target);
bool forward = true;