doubleToString: Fix assert when double is NaN

wholePartSpace asserts that its input is >= 0, but NaN is not a number

Change-Id: Iafc075663d5f8841f21edf0a3d4d36694287a51f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
bb10
Mårten Nordheim 2021-07-26 20:13:09 +02:00
parent 62b33b6730
commit 3b8127c3fc
1 changed files with 1 additions and 1 deletions

View File

@ -3384,7 +3384,7 @@ QString QLocaleData::doubleToString(double d, int precision, DoubleForm form,
int bufSize = 1;
if (precision == QLocale::FloatingPointShortest)
bufSize += std::numeric_limits<double>::max_digits10;
else if (form == DFDecimal)
else if (form == DFDecimal && qIsFinite(d))
bufSize += wholePartSpace(qAbs(d)) + precision;
else // Add extra digit due to different interpretations of precision. Also, "nan" has to fit.
bufSize += qMax(2, precision) + 1;