From 3b8127c3fcf07905180e274c7e554aaa757963c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 26 Jul 2021 20:13:09 +0200 Subject: [PATCH] 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 --- src/corelib/text/qlocale.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index c7cecce37f..d5cde8a69d 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -3384,7 +3384,7 @@ QString QLocaleData::doubleToString(double d, int precision, DoubleForm form, int bufSize = 1; if (precision == QLocale::FloatingPointShortest) bufSize += std::numeric_limits::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;