Skip to content

Fix count variable calculation in typedarray copyWithin #3158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1872,16 +1872,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));
Expand Down