From 10545ca4e7bd875e07830fb17ea0b70b427bc50f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 1 May 2003 17:06:41 +0000 Subject: [PATCH] fix for a crash in ~wxLocale and incorrect GetLanguage() return value (patch 729758) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20413 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/intl.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 50228ca0a1..0d83c0db88 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -614,7 +614,8 @@ bool wxLocale::Init(const wxChar *szName, wxCHECK_MSG( szLocale, FALSE, _T("no locale to set in wxLocale::Init()") ); } - m_pszOldLocale = wxSetlocale(LC_ALL, szLocale); + + m_pszOldLocale = wxStrdup(wxSetlocale(LC_ALL, szLocale)); if ( m_pszOldLocale == NULL ) wxLogError(_("locale '%s' can not be set."), szLocale); @@ -803,12 +804,15 @@ bool wxLocale::Init(int language, int flags) #endif #ifndef WX_NO_LOCALE_SUPPORT - wxChar *szLocale = retloc ? wxStrdup(retloc) : NULL; + wxChar *szLocale = retloc ? wxStrdup(retloc) : NULL; bool ret = Init(name, canonical, retloc, (flags & wxLOCALE_LOAD_DEFAULT) != 0, (flags & wxLOCALE_CONV_ENCODING) != 0); - if (szLocale) - free(szLocale); + free(szLocale); + + if ( ret ) + m_language = lang; + return ret; #endif } @@ -1499,6 +1503,7 @@ wxLocale::~wxLocale() // restore old locale wxSetLocale(m_pOldLocale); wxSetlocale(LC_ALL, m_pszOldLocale); + free((wxChar *)m_pszOldLocale); // const_cast } // get the translation of given string in current locale -- 2.45.2