Fix off-by-one error in integer to string conversions. (#1545)

This commit is contained in:
Nikolay Igotti
2018-04-27 11:57:45 +03:00
committed by GitHub
parent 7e0c19e67a
commit 87a26ec31a
+2 -1
View File
@@ -41,7 +41,8 @@ template <typename T> 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;