fix crash in wxSetEnv(var, NULL) (#9585)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@54228 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-06-15 11:22:52 +00:00
parent 924d65ee97
commit 315ed474f2

View File

@@ -241,8 +241,17 @@ bool wxGetEnv(const wxString& var, wxString *value)
bool wxSetEnv(const wxString& variable, const wxChar *value) bool wxSetEnv(const wxString& variable, const wxChar *value)
{ {
#if defined(HAVE_SETENV) #if defined(HAVE_SETENV)
return setenv(variable.mb_str(), value ? wxString(value).mb_str() if ( !value )
: NULL, 1 /* overwrite */) == 0; {
#ifdef HAVE_UNSETENV
return unsetenv(variable.mb_str()) == 0;
#else
value = _T(""); // mustn't pass NULL to setenv()
#endif
}
return setenv(variable.mb_str(),
wxString(value).mb_str(),
1 /* overwrite */) == 0;
#elif defined(HAVE_PUTENV) #elif defined(HAVE_PUTENV)
wxString s = variable; wxString s = variable;
if ( value ) if ( value )