Skip to content

Commit 5bb3f0f

Browse files
committed
Fix count variable calculation in typedarray copyWithin
Fixes #3130 JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi [email protected]
1 parent 97a0feb commit 5bb3f0f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,16 +1887,16 @@ ecma_builtin_typedarray_prototype_copy_within (ecma_value_t this_arg, /**< this
18871887
}
18881888
}
18891889

1890-
int32_t distance = (int32_t) (end - start);
1891-
int32_t offset = (int32_t) (length - target);
1892-
int32_t count = JERRY_MIN (distance, offset);
1893-
18941890
if (target >= length || end == 0 || start >= end)
18951891
{
18961892
return ecma_copy_value (this_arg);
18971893
}
18981894
else
18991895
{
1896+
uint32_t distance = end - start;
1897+
uint32_t offset = length - target;
1898+
uint32_t count = JERRY_MIN (distance, offset);
1899+
19001900
memmove (typedarray_buffer_p + (target * element_size),
19011901
typedarray_buffer_p + (start * element_size),
19021902
(size_t) (count * element_size));

0 commit comments

Comments
 (0)