From f01ecdb1b05c1a362bf2c750605f23e9e047938f Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 25 Jan 2015 16:53:46 +0000 Subject: [PATCH] Don't leak the individual strings when copying environment. --- usr.bin/tmux/environ.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/usr.bin/tmux/environ.c b/usr.bin/tmux/environ.c index 936f9f0899f..38e7e7c0127 100644 --- a/usr.bin/tmux/environ.c +++ b/usr.bin/tmux/environ.c @@ -1,4 +1,4 @@ -/* $OpenBSD: environ.c,v 1.6 2014/04/17 14:45:49 nicm Exp $ */ +/* $OpenBSD: environ.c,v 1.7 2015/01/25 16:53:46 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -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) { -- 2.20.1