summaryrefslogtreecommitdiff
path: root/missing
diff options
context:
space:
mode:
Diffstat (limited to 'missing')
-rw-r--r--missing/setproctitle.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/missing/setproctitle.c b/missing/setproctitle.c
index 1522657b9b..72e214e51c 100644
--- a/missing/setproctitle.c
+++ b/missing/setproctitle.c
@@ -87,6 +87,7 @@ static char **argv1_addr = NULL;
#endif
#if ALLOCATE_ENVIRON
+static char **system_environ = NULL;
static char **orig_environ = NULL;
static char **alloc_environ = NULL;
#endif
@@ -113,10 +114,10 @@ compat_init_setproctitle(int argc, char *argv[])
/* Fail if we can't allocate room for the new environment */
for (i = 0; envp[i] != NULL; i++);
- orig_environ = environ;
+ system_environ = environ;
alloc_environ = xcalloc(i + 1, sizeof(*environ));
- environ = xcalloc(i + 1, sizeof(*environ));
+ orig_environ = environ = xcalloc(i + 1, sizeof(*environ));
if (environ == NULL) {
environ = envp; /* put it back */
return;
@@ -161,9 +162,9 @@ ruby_free_proctitle(void)
xfree(alloc_environ[i]);
}
xfree(alloc_environ);
- xfree(environ);
+ xfree(orig_environ);
- environ = orig_environ;
+ environ = system_environ;
#endif
}