summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qlocale_win.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2020-01-24 15:48:41 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2020-01-30 18:17:07 +0100
commit3041393d2e6dc094652334fcb4bc35597632d228 (patch)
tree042a1a6aa3b571cccc8bff498422f272f2d3e74b /src/corelib/text/qlocale_win.cpp
parent495db2cd2bb9130864f2dd1291788288765dfe7a (diff)
Fix flawed logic in QSystemLocalePrivate::getLocaleInfo()
If the first call to GetLocaleInfo() returned non-zero, then GetLastError()'s return has nothing to do with GetLocaleInfo(), since it didn't fail. The check for ERROR_INSUFFICIENT_BUFFER as last error needs to happen in the branch where GetLocaleInfo() failed, returning zero. Change-Id: Idb6eaad1515a003133c787998aff0c265ef98251 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/corelib/text/qlocale_win.cpp')
-rw-r--r--src/corelib/text/qlocale_win.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp
index 4b4152c519..d7319c1532 100644
--- a/src/corelib/text/qlocale_win.cpp
+++ b/src/corelib/text/qlocale_win.cpp
@@ -214,9 +214,9 @@ inline int QSystemLocalePrivate::getLocaleInfo(LCTYPE type, LPWSTR data, int siz
QString QSystemLocalePrivate::getLocaleInfo(LCTYPE type, int maxlen)
{
QVarLengthArray<wchar_t, 64> buf(maxlen ? maxlen : 64);
- if (!getLocaleInfo(type, buf.data(), buf.size()))
- return QString();
- if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+ if (!getLocaleInfo(type, buf.data(), buf.size())) {
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+ return QString();
int cnt = getLocaleInfo(type, 0, 0);
if (cnt == 0)
return QString();