diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-07-18 16:27:52 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-07-20 11:15:58 +0000 |
commit | 87fabf3e4b7a5ccc00a7b76b4098e2174e4514d8 (patch) | |
tree | 1eb9c4ae8386f46e0e59df91edb5b12bd75396a0 /src/corelib/text/qlocale_win.cpp | |
parent | 1a40bc37d4c0fa8a79460411635ec02e74215ede (diff) |
QLocale/Win: fix truncation bug in winIso639LangName()
The qstrtoull() function returns ulonglong, not int, so we'd be
incorrectly detecting 0x1'0000'0814 as NyNorsk. Paranoia? Sure.
Fix by using auto to hold the result.
As a drive-by, make the QByteArray const so .data() doesn't
attempt to detach(), and shorten a long variable name to stay
within line-length limitations.
Pick-to: 6.4 6.3 6.2
Task-number: QTBUG-103531
Change-Id: I740d0c5934e54c9f716688fa9c00de0ac4029936
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/text/qlocale_win.cpp')
-rw-r--r-- | src/corelib/text/qlocale_win.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index 0984e82267..47644f6566 100644 --- a/src/corelib/text/qlocale_win.cpp +++ b/src/corelib/text/qlocale_win.cpp @@ -1075,8 +1075,8 @@ static QString winIso639LangName(LCID id) if (!lang_code.isEmpty()) { const char *endptr; bool ok; - QByteArray latin1_lang_code = std::move(lang_code).toLatin1(); - int i = qstrntoull(latin1_lang_code.data(), latin1_lang_code.size(), &endptr, 16, &ok); + const QByteArray latin1 = std::move(lang_code).toLatin1(); + const auto i = qstrntoull(latin1.data(), latin1.size(), &endptr, 16, &ok); if (ok && *endptr == '\0') { switch (i) { case 0x814: |