From 5e429702bfa1dd62ffcd26031f5d155e3c3870a8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 10 Dec 2017 00:03:39 +0100 Subject: [PATCH] Fix fatal bug in wxXLocale initialization Ensure that m_locale is always initialized to null pointer, as it could remain not initialized at all if information for wxLanguage could be found, but its locale name was empty, which resulted in a crash in dtor when the wxXLocale object was destroyed as freelocale() was called with an invalid pointer. --- src/common/xlocale.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/common/xlocale.cpp b/src/common/xlocale.cpp index 02c9d2ca2d..e8095a1132 100644 --- a/src/common/xlocale.cpp +++ b/src/common/xlocale.cpp @@ -90,12 +90,10 @@ wxXLocale& wxXLocale::GetCLocale() #if wxUSE_INTL wxXLocale::wxXLocale(wxLanguage lang) { + m_locale = NULL; + const wxLanguageInfo * const info = wxLocale::GetLanguageInfo(lang); - if ( !info ) - { - m_locale = NULL; - } - else + if ( info ) { Init(info->GetLocaleName().c_str()); }