aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-01-03 20:17:16 -0600
committerRob Landley <rob@landley.net>2020-01-03 20:17:16 -0600
commit2c6b319f4686c35f7d6fabc494a319702844f3d6 (patch)
treeedd5ee702408660163735e8c15fa4c5876168f7a /lib
parent9840fcdb428c712d21b057241e72ac9715ff6b28 (diff)
downloadtoybox-2c6b319f4686c35f7d6fabc494a319702844f3d6.tar.gz
Only free the environment variables we didn't inherit from exec.
Diffstat (limited to 'lib')
-rw-r--r--lib/env.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/env.c b/lib/env.c
index af0ec29d..33ad0005 100644
--- a/lib/env.c
+++ b/lib/env.c
@@ -23,9 +23,9 @@ long environ_bytes()
void xclearenv(void)
{
if (toys.envc) {
- char **ss;
+ int i;
- for (ss = environ; *ss; ss++) free(*ss);
+ for (i = 0; environ[i]; i++) if (i>=toys.envc) free(environ[i]);
free(environ);
}
toys.envc = 0;