From e36457c0436a6205570f5f442565dbb08f59ac3b Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 24 Nov 2022 17:50:02 +0100 Subject: [PATCH] Fix out-of-bounds assert in winIso639LangName() QByteArray doesn't allow accessing, with operator[], the '\0' byte it stores at index size(). Previously we accessed it indirectly by dereferencing a pointer offset from its data() instead of indexing; my recent change converted the return of an endptr to the return of its index, so used operator[]. This is a follow-up to commit 6c435e5dd41177308f22ba4b55931b2c463cb0d8 Change-Id: I9faf9dfa3dcc8df1e841e5538e452afef9ba610c Reviewed-by: Thiago Macieira Reviewed-by: Qt CI Bot Reviewed-by: Alessandro Portale --- src/corelib/text/qlocale_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index 1a31d8e90c1..9625f7bf7b7 100644 --- a/src/corelib/text/qlocale_win.cpp +++ b/src/corelib/text/qlocale_win.cpp @@ -1076,7 +1076,7 @@ static QString winIso639LangName(LCID id) if (!lang_code.isEmpty()) { const QByteArray latin1 = std::move(lang_code).toLatin1(); const auto [i, used] = qstrntoull(latin1.data(), latin1.size(), 16); - if (used > 0 && latin1[used] == '\0') { + if (used >= latin1.size() || (used > 0 && latin1[used] == '\0')) { switch (i) { case 0x814: result = u"nn"_s; // Nynorsk