Fix wxLanguageInfo::GetLocaleName()

This function could (and did) return completely wrong results because
the value of the pointer returned by setlocale() could be (and was)
changed by the subsequent call to setlocale() with different arguments.

Fix the problem by copying the returned value into wxString immediately,
without any intervening setlocale() calls.
This commit is contained in:
Vadim Zeitlin
2017-12-10 00:10:38 +01:00
parent 5e429702bf
commit 17041075b4

View File

@@ -208,12 +208,17 @@ wxString wxLanguageInfo::GetLocaleName() const
const char* const orig = wxSetlocale(LC_ALL, NULL);
const char* const ret = TrySetLocale();
if ( !ret )
return wxString();
wxString retval;
if ( ret )
{
// Note that we must copy the returned value before calling setlocale()
// again as the string "ret" points to can (and, at least under Linux
// with glibc, actually always will) be changed by this call.
retval = ret;
wxSetlocale(LC_ALL, orig);
}
return ret;
return retval;
}
// ----------------------------------------------------------------------------