Skip to content

Fix length check for typedarray copyWithin #3108

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
Sep 17, 2019

Conversation

szilagyiadam
Copy link
Contributor

@szilagyiadam szilagyiadam commented Sep 13, 2019

We should check if the start index is equal or greater than the end index,
if thats the case, we should return with the original typedArray.

Fixes #3107

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu

@@ -1891,7 +1891,7 @@ ecma_builtin_typedarray_prototype_copy_within (ecma_value_t this_arg, /**< this
int32_t offset = (int32_t) (length - target);
int32_t count = JERRY_MIN (distance, offset);

if (target >= length || start >= length || end == 0)
if (target >= length || start >= length || end == 0 || start >= end)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the start >= length condition just be replaced with start >= end? It seems to me that end is always <= length.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats a good point, i will fix it!

@dbatyai
Copy link
Member

dbatyai commented Sep 13, 2019

The commit message could also be a bit more specific about what kind of check is being added.

Copy link
Member

@rerobika rerobika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@szilagyiadam szilagyiadam changed the title Add new check to typedarray copyWithin Fix length check for typedarray copyWithin Sep 16, 2019
We should check if the start index is equal or greater than the end index,
if thats the case, we should return with the original typedArray.

Fixes jerryscript-project#3107

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
Copy link
Member

@rerobika rerobika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@dbatyai dbatyai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dbatyai dbatyai merged commit 0eae2f6 into jerryscript-project:master Sep 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

negative-size-param in memmove (ecma-builtin-typedarray-prototype.c)
3 participants