From 3041393d2e6dc094652334fcb4bc35597632d228 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 24 Jan 2020 15:48:41 +0100 Subject: 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 --- src/corelib/text/qlocale_win.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') 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 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(); -- cgit v1.2.3