From 0f754ff33cbb0831d52f5af30498efe32b81025d Mon Sep 17 00:00:00 2001 From: Szilagyi Adam Date: Mon, 7 Oct 2019 11:31:44 +0200 Subject: [PATCH] Fix count variable calculation in typedarray copyWithin (#3158) Fixes #3130 JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu --- .../typedarray/ecma-builtin-typedarray-prototype.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c index 94574c004..16b9d14b7 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c @@ -1873,16 +1873,16 @@ ecma_builtin_typedarray_prototype_copy_within (ecma_value_t this_arg, /**< this } } - int32_t distance = (int32_t) (end - start); - int32_t offset = (int32_t) (info.typedarray_length - target); - int32_t count = JERRY_MIN (distance, offset); - if (target >= info.typedarray_length || start >= end || end == 0) { return ecma_copy_value (this_arg); } else { + uint32_t distance = end - start; + uint32_t offset = info.typedarray_length - target; + uint32_t count = JERRY_MIN (distance, offset); + memmove (info.buffer_p + (target * info.element_size), info.buffer_p + (start * info.element_size), (size_t) (count * info.element_size));