diff --git a/Sources/Plasma/CoreLib/plFormat.cpp b/Sources/Plasma/CoreLib/plFormat.cpp index 2b2ae1e1..2f6ddb3e 100644 --- a/Sources/Plasma/CoreLib/plFormat.cpp +++ b/Sources/Plasma/CoreLib/plFormat.cpp @@ -190,6 +190,11 @@ namespace plFormat_Private template void _IFormatNumeric_Impl(char *output_end, _IType value, int radix, bool upperCase = false) { + if (value == 0) { + *(output_end - 1) = '0'; + return; + } + while (value) { int digit = (value % radix); @@ -218,6 +223,9 @@ static plStringBuffer _formatNumeric(const plFormat_Private::FormatSpec &f temp /= radix; } + if (max == 0) + max = 1; + plStringBuffer buffer; if (format.fPrecisionLeft > max) { char *output = buffer.CreateWritableBuffer(format.fPrecisionLeft); @@ -252,6 +260,9 @@ static plStringBuffer _formatDecimal(const plFormat_Private::FormatSpec &f temp /= 10; } + if (max == 0) + max = 1; + if (value < 0 || format.fDigitClass == plFormat_Private::kDigitDecAlwaysSigned) ++max;