-
Notifications
You must be signed in to change notification settings - Fork 684
Fix a bug in ArrayBuffer #1479
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
Fix a bug in ArrayBuffer #1479
Conversation
@@ -50,8 +50,11 @@ ecma_op_create_arraybuffer_object (const ecma_value_t *arguments_list_p, /**< li | |||
|
|||
if (arguments_list_len > 0) | |||
{ | |||
ecma_number_t num = ecma_get_number_from_value (ecma_op_to_number (arguments_list_p[0])); | |||
ecma_value_t num_value = ecma_op_to_number (arguments_list_p[0]); |
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.
This can also be a conversion exception.
|
||
try | ||
{ | ||
var a = new ArrayBuffer(5.5); |
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.
There should be another case with:
var a = new ArrayBuffer("a string");
Or something non-number.
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.
After the minor style fix, LGTM.
@@ -50,12 +50,21 @@ ecma_op_create_arraybuffer_object (const ecma_value_t *arguments_list_p, /**< li | |||
|
|||
if (arguments_list_len > 0) | |||
{ | |||
ecma_number_t num = ecma_get_number_from_value (ecma_op_to_number (arguments_list_p[0])); | |||
ecma_value_t ret = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY); | |||
ECMA_OP_TO_NUMBER_TRY_CATCH (num, arguments_list_p[0], ret); |
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.
Please put a newline before ECMA_OP_TO_NUMBER_TRY_CATCH.
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
Excellent patch! |
I hope you don't mind that I changed the patch description a bit. But please be a bit more verbose in the future. |
* free_value after ecma_op_to_number * add related test file JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang [email protected]
JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang [email protected]