From 87fabf3e4b7a5ccc00a7b76b4098e2174e4514d8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 18 Jul 2022 16:27:52 +0200 Subject: [PATCH] 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 Reviewed-by: Edward Welbourne --- src/corelib/text/qlocale_win.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index 0984e822672..47644f6566f 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: