From 2c6b319f4686c35f7d6fabc494a319702844f3d6 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 3 Jan 2020 20:17:16 -0600 Subject: Only free the environment variables we didn't inherit from exec. --- lib/env.c | 4 ++-- 1 file 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; -- cgit v1.2.3