From ca85e1246eacfe7ba570882a674e313be3b808f8 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 20 Jan 2020 13:44:30 +0100 Subject: updateSystemPrivate(): fix handling of empty string as non-null QVariant QSystemLocale::query() can return an empty string for PositiveSign on Windows, apparently. In any case, we shouldn't be taking .at(0) of a QString without checking it's non-empty. Fixes: QTBUG-81530 Change-Id: I4d496a2650362f225d02998bd7b8be9fd783edb4 Reviewed-by: Friedemann Kleint --- src/corelib/text/qlocale.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index d8c4b41624..26db674a99 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -734,23 +734,23 @@ static void updateSystemPrivate() globalLocaleData.m_script_id = res.toInt(); res = sys_locale->query(QSystemLocale::DecimalPoint, QVariant()); - if (!res.isNull()) + if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_decimal = res.toString().at(0).unicode(); res = sys_locale->query(QSystemLocale::GroupSeparator, QVariant()); - if (!res.isNull()) + if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_group = res.toString().at(0).unicode(); res = sys_locale->query(QSystemLocale::ZeroDigit, QVariant()); - if (!res.isNull()) + if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_zero = res.toString().at(0).unicode(); res = sys_locale->query(QSystemLocale::NegativeSign, QVariant()); - if (!res.isNull()) + if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_minus = res.toString().at(0).unicode(); res = sys_locale->query(QSystemLocale::PositiveSign, QVariant()); - if (!res.isNull()) + if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_plus = res.toString().at(0).unicode(); } #endif // !QT_NO_SYSTEMLOCALE -- cgit v1.2.3