diff options
author | Magnus Hagander | 2009-02-12 12:53:34 +0000 |
---|---|---|
committer | Magnus Hagander | 2009-02-12 12:53:34 +0000 |
commit | b31d0719fbd9362564d560f2ea776b50392e41d0 (patch) | |
tree | bcd3a2ecc08b1ebf6d31edbbc21b4d32ddffe12f /src/port/win32env.c | |
parent | 6d1e36185208d04c72d4550c5b02f6f282c9db4f (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.
Diffstat (limited to 'src/port/win32env.c')
-rw-r--r-- | src/port/win32env.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/port/win32env.c b/src/port/win32env.c index 7533549608c..36888286b7f 100644 --- a/src/port/win32env.c +++ b/src/port/win32env.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/win32env.c,v 1.1 2009/01/21 10:30:02 mha Exp $ + * $PostgreSQL: pgsql/src/port/win32env.c,v 1.2 2009/02/12 12:53:34 mha Exp $ * *------------------------------------------------------------------------- */ @@ -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); |