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) Task-number: QTBUG-111443 Change-Id: I6f518d59e63249ddbf43fffd1759d28738124797 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 3690c202f959a505e0f0bcd4a7b19f235b04d015) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
ae6ec20349
commit
cf7d972866
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user