Don't leak the individual strings when copying environment.

This commit is contained in:
nicm 2015-01-25 16:53:46 +00:00
parent c38f0d85da
commit adcc71d4d5

View File

@ -168,8 +168,11 @@ environ_push(struct environ *env)
var[strcspn(var, "=")] = '\0';
ARRAY_ADD(&varlist, var);
}
for (i = 0; i < ARRAY_LENGTH(&varlist); i++)
unsetenv(ARRAY_ITEM(&varlist, i));
for (i = 0; i < ARRAY_LENGTH(&varlist); i++) {
var = ARRAY_ITEM(&varlist, i);
unsetenv(var);
free(var);
}
ARRAY_FREE(&varlist);
RB_FOREACH(envent, environ, env) {