-
Notifications
You must be signed in to change notification settings - Fork 683
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
Conversation
e86ae12
to
b30fea7
Compare
@@ -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) |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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!
The commit message could also be a bit more specific about what kind of check is being added. |
b30fea7
to
f65961a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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
f65961a
to
877b5fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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