From: Thiago Macieira Date: Fri, 24 Jan 2025 18:28:30 +0000 (-0800) Subject: [PATCH] QSystemLocale: bail out if accessed post-destruction X-Git-Tag: archive/raspbian/6.8.2+dfsg-7+rpi1^2~12 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d0e3676a0e449cffaacd0331d5141a4be53382a0;p=qt6-base.git [PATCH] QSystemLocale: bail out if accessed post-destruction There's little we can do, but a lot of content ends up in QLocale very late in the execution. Let's at least not crash. Task-number: QTBUG-133206 Change-Id: I77d41141cb115147f9befffdd5e69dac19c96044 Reviewed-by: Albert Astals Cid Reviewed-by: Edward Welbourne (cherry picked from commit e32f28034ad2383393645777bcd96eab3f696076) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit d5c5f9f3529b384d0d4bea2d51f0ad6a3d57481d) Gbp-Pq: Name upstream_qsystemlocale_post_destruction_access.patch --- diff --git a/src/corelib/text/qlocale_unix.cpp b/src/corelib/text/qlocale_unix.cpp index a934f24c..91dbb74c 100644 --- a/src/corelib/text/qlocale_unix.cpp +++ b/src/corelib/text/qlocale_unix.cpp @@ -127,6 +127,8 @@ QLocale QSystemLocale::fallbackLocale() const QVariant QSystemLocale::query(QueryType type, QVariant &&in) const { QSystemLocaleData *d = qSystemLocaleData(); + if (!d) + return QVariant(); if (type == LocaleChanged) { d->readEnvironment(); diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index 9fdb46a4..793751da 100644 --- a/src/corelib/text/qlocale_win.cpp +++ b/src/corelib/text/qlocale_win.cpp @@ -828,6 +828,8 @@ QLocale QSystemLocale::fallbackLocale() const QVariant QSystemLocale::query(QueryType type, QVariant &&in) const { QSystemLocalePrivate *d = systemLocalePrivate(); + if (!d) + return QVariant(); switch(type) { case DecimalPoint: return d->decimalPoint();