Skip to content

Commit

Permalink
doubleToString: Fix assert when double is NaN
Browse files Browse the repository at this point in the history
wholePartSpace asserts that its input is >= 0, but NaN is not a number

Change-Id: Iafc075663d5f8841f21edf0a3d4d36694287a51f
Reviewed-by: Edward Welbourne <[email protected]>
  • Loading branch information
Morten242 committed Jul 27, 2021
1 parent 62b33b6 commit 3b8127c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/corelib/text/qlocale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3b8127c

Please sign in to comment.