From a0cb7c1291e9fed731c3b99c4e2138bbe9937d9a Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Thu, 2 Mar 2017 07:48:08 -0800 Subject: [PATCH] Avoid using stale nl_langinfo() pointer See #17813 --- src/common/intl.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 98140e22a7..24f49d433e 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -824,15 +824,11 @@ wxString wxLocale::GetSystemEncodingName() // to Unix98) char *oldLocale = strdup(setlocale(LC_CTYPE, NULL)); setlocale(LC_CTYPE, ""); - const char *alang = nl_langinfo(CODESET); + encname = wxString::FromAscii(nl_langinfo(CODESET)); setlocale(LC_CTYPE, oldLocale); free(oldLocale); - if ( alang ) - { - encname = wxString::FromAscii( alang ); - } - else // nl_langinfo() failed + if (encname.empty()) #endif // HAVE_LANGINFO_H { // if we can't get at the character set directly, try to see if it's in