Skip to content

Commit 0f754ff

Browse files
szilagyiadamrerobika
authored andcommitted
Fix count variable calculation in typedarray copyWithin (#3158)
Fixes #3130 JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi [email protected]
1 parent 3e23a3b commit 0f754ff

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
@@ -1873,16 +1873,16 @@ ecma_builtin_typedarray_prototype_copy_within (ecma_value_t this_arg, /**< this
18731873
}
18741874
}
18751875

1876-
int32_t distance = (int32_t) (end - start);
1877-
int32_t offset = (int32_t) (info.typedarray_length - target);
1878-
int32_t count = JERRY_MIN (distance, offset);
1879-
18801876
if (target >= info.typedarray_length || start >= end || end == 0)
18811877
{
18821878
return ecma_copy_value (this_arg);
18831879
}
18841880
else
18851881
{
1882+
uint32_t distance = end - start;
1883+
uint32_t offset = info.typedarray_length - target;
1884+
uint32_t count = JERRY_MIN (distance, offset);
1885+
18861886
memmove (info.buffer_p + (target * info.element_size),
18871887
info.buffer_p + (start * info.element_size),
18881888
(size_t) (count * info.element_size));

0 commit comments

Comments
 (0)