diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-04-27 07:55:34 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-04-28 20:30:12 -0700 |
commit | 3690c202f959a505e0f0bcd4a7b19f235b04d015 (patch) | |
tree | fe757ea18b79f0c5f6a18a8d83cbb18e213350c9 | |
parent | 58ebbb62203ec31e03d3ee0bc58c57de5b3bcce4 (diff) | |
download | qtbase-3690c202f959a505e0f0bcd4a7b19f235b04d015.tar.gz |
QCoreApplication: fix use-after-free of nl_langinfo() result
The result is retained so long as we don't attempt to change our locale,
but failing to change that is the reason why we printed anything.
==20227==ERROR: AddressSanitizer: heap-use-after-free on address 0x000107312696 at pc 0x000103c48088 bp 0x00016ee180c0 sp 0x00016ee17880
READ of size 9 at 0x000107312696 thread T0
#0 0x103c48084 in wrap_strlen+0x164 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x18084) (BuildId: f0a7ac5c49bc3abc851181b6f92b308a32000000200000000100000000000b00)
#1 0x1023804bc in QString::vasprintf(char const*, char*) qstring.cpp:7112
#2 0x102243578 in qt_message(QtMsgType, QMessageLogContext const&, char const*, char*) qlogging.cpp:368
#3 0x10252630c in QMessageLogger::warning(char const*, ...) const qlogging.cpp:647
#4 0x10229f940 in QCoreApplicationPrivate::initLocale() qcoreapplication.cpp:664
#5 0x10229fba0 in QCoreApplicationPrivate::init() qcoreapplication.cpp:826
#6 0x1022a07c0 in QCoreApplication::QCoreApplication(int&, char**, int) qcoreapplication.cpp:799
#7 0x101454ef8 in main+0xeb0 (WSgen:arm64+0x100470ef8) (BuildId: ae9b4fec1fd73c1693047a6b9d9ce91432000000200000000100000000000b00)
Pick-to: 6.5
Task-number: QTBUG-111443
Change-Id: I6f518d59e63249ddbf43fffd1759d28738124797
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 064a323507..3b622961c1 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -658,14 +658,14 @@ void QCoreApplicationPrivate::initLocale() qWarning("Detected locale \"%s\" with character encoding \"%s\", which is not UTF-8.\n" "Qt depends on a UTF-8 locale, but has failed to switch to one.\n" "If this causes problems, reconfigure your locale. See the locale(1) manual\n" - "for more information.", oldLocale.constData(), charEncoding); + "for more information.", oldLocale.constData(), nl_langinfo(CODESET)); } else if (warnOnOverride) { // Let the user know we over-rode their configuration. qWarning("Detected locale \"%s\" with character encoding \"%s\", which is not UTF-8.\n" "Qt depends on a UTF-8 locale, and has switched to \"%s\" instead.\n" "If this causes problems, reconfigure your locale. See the locale(1) manual\n" "for more information.", - oldLocale.constData(), charEncoding, newLocale.constData()); + oldLocale.constData(), nl_langinfo(CODESET), newLocale.constData()); } } # endif // Platform choice |