Fix assertion fails in parseInt()

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com
This commit is contained in:
Dániel Bátyai
2015-08-05 12:49:40 +02:00
parent 8df6cdd1e9
commit cf1eda0981
2 changed files with 148 additions and 127 deletions
@@ -236,6 +236,8 @@ ecma_builtin_global_object_parse_int (ecma_value_t this_arg __attr_unused___, /*
} }
} }
if (!lit_utf8_iterator_is_eos (&iter))
{
/* 3. */ /* 3. */
int sign = 1; int sign = 1;
@@ -353,7 +355,14 @@ ecma_builtin_global_object_parse_int (ecma_value_t this_arg __attr_unused___, /*
ecma_number_t multiplier = 1.0f; ecma_number_t multiplier = 1.0f;
/* 13. and 14. */ /* 13. and 14. */
if (end.offset < str_size)
{
lit_utf8_iterator_seek (&iter, end); lit_utf8_iterator_seek (&iter, end);
}
else
{
lit_utf8_iterator_seek_eos (&iter);
}
while (lit_utf8_iterator_get_pos (&iter).offset > start.offset) while (lit_utf8_iterator_get_pos (&iter).offset > start.offset)
{ {
ecma_char_t current_char = lit_utf8_iterator_read_prev (&iter); ecma_char_t current_char = lit_utf8_iterator_read_prev (&iter);
@@ -390,6 +399,14 @@ ecma_builtin_global_object_parse_int (ecma_value_t this_arg __attr_unused___, /*
} }
ECMA_OP_TO_NUMBER_FINALIZE (radix_num); ECMA_OP_TO_NUMBER_FINALIZE (radix_num);
}
else
{
ecma_number_t *ret_num_p = ecma_alloc_number ();
*ret_num_p = ecma_number_make_nan ();
ret_value = ecma_make_normal_completion_value (ecma_make_number_value (ret_num_p));
}
MEM_FINALIZE_LOCAL_ARRAY (utf8_string_buff); MEM_FINALIZE_LOCAL_ARRAY (utf8_string_buff);
} }
else else
+4
View File
@@ -34,6 +34,10 @@ assert(parseInt("\u00a0123") === 123);
assert(parseInt("\u20291 123\u00D0") === 1); assert(parseInt("\u20291 123\u00D0") === 1);
assert(parseInt("\u00a0123", 13) === 198); assert(parseInt("\u00a0123", 13) === 198);
assert(parseInt("\u2029123 1\u00D0", 11) === 146); assert(parseInt("\u2029123 1\u00D0", 11) === 146);
assert(isNaN(parseInt("\u0009")));
assert(isNaN(parseInt("\u00A0")));
assert(parseInt("\u00A0\u00A0-1") === parseInt("-1"));
assert(parseInt("\u00A01") === parseInt("1"));
var bool = true; var bool = true;
var obj = new Object(); var obj = new Object();