summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--stdlib/setenv.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/stdlib/setenv.c b/stdlib/setenv.c
index 3043498103..6b5f9be8d5 100644
--- a/stdlib/setenv.c
+++ b/stdlib/setenv.c
@@ -146,6 +146,11 @@ __add_to_environ (name, value, combined, replace)
UNLOCK;
return -1;
}
+
+ if (__environ != last_environ)
+ memcpy ((char *) new_environ, (char *) __environ,
+ size * sizeof (char *));
+
new_environ[size] = NULL;
new_environ[size + 1] = NULL;
ep = new_environ + size;