diff options
author | Magnus Hagander | 2009-02-12 12:53:34 +0000 |
---|---|---|
committer | Magnus Hagander | 2009-02-12 12:53:34 +0000 |
commit | 10ce74def79e33bdddbab4ca8d30e85f632bc1fd (patch) | |
tree | 63eade542bf8797e40283d1d5d7fbf71058b5343 | |
parent | ab77dec0d1f9567892b6d818739f64a9492ed853 (diff) |
Don't call SetEnvironmentVariable() when removing an environment variable,
as this seems to crash on at least some versions of MingW. Our current usage
of this function does not require it, so it should be ok to ignore.
-rw-r--r-- | src/port/win32env.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/port/win32env.c b/src/port/win32env.c index 9e8565aa70..26ddf3bfed 100644 --- a/src/port/win32env.c +++ b/src/port/win32env.c @@ -64,12 +64,18 @@ pgwin32_putenv(const char *envval) return -1; *cp = '\0'; cp++; - if (strlen(cp) == 0) - cp = NULL; - if (!SetEnvironmentVariable(envcpy, cp)) + if (strlen(cp)) { - free(envcpy); - return -1; + /* + * Only call SetEnvironmentVariable() when we are adding a variable, + * not when removing it. Calling it on both crashes on at least certain + * versions of MingW. + */ + if (!SetEnvironmentVariable(envcpy, cp)) + { + free(envcpy); + return -1; + } } free(envcpy); |