summaryrefslogtreecommitdiff
path: root/src/common/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/exec.c')
-rw-r--r--src/common/exec.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/common/exec.c b/src/common/exec.c
index d736b02280..bd01c2d9a2 100644
--- a/src/common/exec.c
+++ b/src/common/exec.c
@@ -4,7 +4,7 @@
* Functions for finding and validating executable files
*
*
- * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
@@ -35,7 +35,7 @@
#define log_error4(str, param, arg1) (fprintf(stderr, str, param, arg1), fputc('\n', stderr))
#endif
-#ifdef WIN32_ONLY_COMPILER
+#ifdef _MSC_VER
#define getcwd(cwd,len) GetCurrentDirectory(len, cwd)
#endif
@@ -553,6 +553,7 @@ set_pglocale_pgservice(const char *argv0, const char *app)
char my_exec_path[MAXPGPATH];
char env_path[MAXPGPATH + sizeof("PGSYSCONFDIR=")]; /* longer than
* PGLOCALEDIR */
+ char *dup_path;
/* don't set LC_ALL in the backend */
if (strcmp(app, PG_TEXTDOMAIN("postgres")) != 0)
@@ -583,7 +584,9 @@ set_pglocale_pgservice(const char *argv0, const char *app)
/* set for libpq to use */
snprintf(env_path, sizeof(env_path), "PGLOCALEDIR=%s", path);
canonicalize_path(env_path + 12);
- putenv(strdup(env_path));
+ dup_path = strdup(env_path);
+ if (dup_path)
+ putenv(dup_path);
}
#endif
@@ -594,7 +597,9 @@ set_pglocale_pgservice(const char *argv0, const char *app)
/* set for libpq to use */
snprintf(env_path, sizeof(env_path), "PGSYSCONFDIR=%s", path);
canonicalize_path(env_path + 13);
- putenv(strdup(env_path));
+ dup_path = strdup(env_path);
+ if (dup_path)
+ putenv(dup_path);
}
}