From 6f41c10973643552837c6bd38b23779e65a2eaa3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Jun 2012 16:33:40 +0000 Subject: [PATCH] Force wide char environment version initialization in wxGetEnvMap(). When using MSVC CRT, the wide character version of the environment is not always initialized when using main() (and not _wmain()) as entry point, so force initializing it before using _tenviron. Closes #14231. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71893 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/utilscmn.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 535c455..147b374 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -551,6 +551,11 @@ bool wxGetEnvMap(wxEnvVariableHashMap *map) wxCHECK_MSG( map, false, wxS("output pointer can't be NULL") ); #if defined(__VISUALC__) + // This variable only exists to force the CRT to fill the wide char array, + // it might only have it in narrow char version until now as we use main() + // (and not _wmain()) as our entry point. + static wxChar* s_dummyEnvVar = _tgetenv(wxT("TEMP")); + wxChar **env = _tenviron; #elif defined(__VMS) // Now this routine wil give false for OpenVMS -- 2.7.4