From 3ff9a7de8a21c5bd05cb231c4137c808f9f5af3e Mon Sep 17 00:00:00 2001 From: Robert Sipka Date: Thu, 30 Mar 2017 10:40:05 +0200 Subject: [PATCH] Fix the number of copied bytes in memmove (#1698) Fixes #1634 JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com --- jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c | 2 +- tests/jerry/number-prototype-to-string.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c index 1b1851577..c024e0e7c 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c @@ -398,7 +398,7 @@ ecma_builtin_number_prototype_object_to_string (ecma_value_t this_arg, /**< this /* Place radix point to the required position. */ if (point < buff_index) { - memmove (buff + point + 1, buff + point, (size_t) buff_index); + memmove (buff + point + 1, buff + point, (size_t) (buff_index - point)); buff[point] = '.'; buff_index++; } diff --git a/tests/jerry/number-prototype-to-string.js b/tests/jerry/number-prototype-to-string.js index f40be51fc..45acfb58a 100644 --- a/tests/jerry/number-prototype-to-string.js +++ b/tests/jerry/number-prototype-to-string.js @@ -90,6 +90,8 @@ assert ((-0x100000000000061).toString(16) === "-100000000000060"); assert((123400).toString(new Number(16)) === "1e208"); +assert(65535.9.toString(3) === "10022220020.220022002200220022002210211012200000110221"); + var digit_chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',