Skip to content

Commit 84f09ff

Browse files
LaszloLangoegavrin
authored andcommitted
Follow up fix for Date.prototype.toString
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
1 parent dcc704d commit 84f09ff

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ ecma_date_insert_leading_zeros (ecma_string_t **str_p, /**< input/output string
5353
JERRY_ASSERT (length >= 1);
5454

5555
/* If the length is bigger than the number of digits in num, then insert leding zeros. */
56-
for (uint32_t i = length - 1; i > 0 && num < pow (10,i); i--)
56+
uint32_t first_index = length - 1u;
57+
ecma_number_t power_i = (ecma_number_t) pow (10, first_index);
58+
for (uint32_t i = first_index; i > 0 && num < power_i; i--, power_i /= 10)
5759
{
5860
ecma_string_t *zero_str_p = ecma_new_ecma_string_from_uint32 (0);
5961
ecma_string_t *concat_p = ecma_concat_ecma_strings (zero_str_p, *str_p);

0 commit comments

Comments
 (0)