-
Notifications
You must be signed in to change notification settings - Fork 682
Fix assertion 'bytes_copied > 0 || !string_len' in JSON.stringify() #491
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 assertion 'bytes_copied > 0 || !string_len' in JSON.stringify() #491
Conversation
Solution for #406 |
9582c1c
to
1419e37
Compare
@@ -1117,11 +1117,11 @@ ecma_builtin_json_stringify (ecma_value_t this_arg __attr_unused___, /**< 'this' | |||
{ | |||
ecma_length_t string_len = ecma_string_get_length (space_str_p); |
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.
Are you sure this is length not size?
1419e37
to
d08c5ec
Compare
LGTM |
|
||
context_p.gap_str_p = ecma_new_ecma_string_from_utf8 ((lit_utf8_byte_t *) space_buff, 10); | ||
context_p.gap_str_p = ecma_new_ecma_string_from_utf8 ((lit_utf8_byte_t *) space_buff, space_buff_size); |
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.
Do we really need space_buff?
As I see, we can just call ecma_new_ecma_string_from_utf8 (string_buff, space_buff_size)
.
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.
hm... You are right, we don't need space_buff.
Updating.
d08c5ec
to
fe67b75
Compare
|
||
MEM_FINALIZE_LOCAL_ARRAY (space_buff); | ||
MEM_FINALIZE_LOCAL_ARRAY (zt_string_buff); | ||
MEM_FINALIZE_LOCAL_ARRAY (string_buff); |
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.
To extract a substirng, it is better to use:
context_p.gap_str_p = ecma_string_substr (space_str_p, 0, 10)
.
Sorry, noticed just now, that this fragment could be simplified so much.
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.
nice! FIxed :)
a83cd9d
to
5f296ba
Compare
LGTM. |
b79e960
to
4ac18b8
Compare
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs.u-szeged@partner.samsung.com
4ac18b8
to
5888401
Compare
Modified some places to support unicode characters.
Also renamed some variables to be more clearer.