summaryrefslogtreecommitdiffstats
path: root/environ.c
diff options
context:
space:
mode:
authornicm <nicm>2016-01-15 11:33:41 +0000
committernicm <nicm>2016-01-15 11:33:41 +0000
commitd551ab8e5cfb00fbb7a79e7f0c3f4f2780fc6824 (patch)
tree8c426560cf2ebbbd2274d886249d024c55b327cd /environ.c
parent68d797587ef2acf1464a9390912e4a22e4db6482 (diff)
Clear the environment properly by looping until it is empty rather than
looping over it (which may skip entries), from Brad King.
Diffstat (limited to 'environ.c')
-rw-r--r--environ.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/environ.c b/environ.c
index de560896..101dfafd 100644
--- a/environ.c
+++ b/environ.c
@@ -196,10 +196,10 @@ void
environ_push(struct environ *env)
{
struct environ_entry *envent;
- char **vp, *v;
+ char *v;
- for (vp = environ; *vp != NULL; vp++) {
- v = xstrdup(*vp);
+ while (*environ != NULL) {
+ v = xstrdup(*environ);
v[strcspn(v, "=")] = '\0';
unsetenv(v);