Fix restoring locale in SetArguments()

The string returned by setlocale() can be overwritten by subsequent calls,
so make a copy of it. See #18203
This commit is contained in:
Paul Cornett
2018-08-22 00:00:43 -07:00
parent 14c121b469
commit 1f8481eabc

View File

@@ -429,9 +429,9 @@ void wxCmdLineParserData::SetArguments(int argc, char **argv)
// temporarily change the locale here. The only drawback is that changing
// the locale is thread-unsafe but precisely because we're called so early
// it's hopefully safe to assume that no other threads had been created yet.
char * const locOld = SetAllLocaleFacets(NULL);
const wxCharBuffer locOld(SetAllLocaleFacets(NULL));
SetAllLocaleFacets("");
wxON_BLOCK_EXIT1( SetAllLocaleFacets, locOld );
wxON_BLOCK_EXIT1( SetAllLocaleFacets, locOld.data() );
for ( int n = 0; n < argc; n++ )
{