From 87a26ec31a3bfa08cd1fe83e0431103497d03f96 Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Fri, 27 Apr 2018 11:57:45 +0300 Subject: [PATCH] Fix off-by-one error in integer to string conversions. (#1545) --- runtime/src/main/cpp/ToString.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/src/main/cpp/ToString.cpp b/runtime/src/main/cpp/ToString.cpp index f9aca84d044..b4895db60ec 100644 --- a/runtime/src/main/cpp/ToString.cpp +++ b/runtime/src/main/cpp/ToString.cpp @@ -41,7 +41,8 @@ template OBJ_GETTER(Kotlin_toStringRadix, T value, KInt radix) { if (value == 0) { RETURN_RESULT_OF(CreateStringFromCString, "0"); } - char cstring[sizeof(T) * CHAR_BIT + 1]; + // In the worst case, we convert to binary, with sign. + char cstring[sizeof(T) * CHAR_BIT + 2]; bool negative = (value < 0); if (!negative) { value = -value;