diff options
author | Tom Gundersen <teg@jklm.no> | 2015-05-25 22:55:52 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-05-25 22:58:26 +0200 |
commit | 2371271c2acaeab31e232b6749f12aeac7c18348 (patch) | |
tree | c458cc3817c934fe0de796f8dec55f97dbbc76c3 /src/nspawn | |
parent | nspawn: drop some debugging code (diff) | |
download | systemd-2371271c2acaeab31e232b6749f12aeac7c18348.tar.xz systemd-2371271c2acaeab31e232b6749f12aeac7c18348.zip |
nspawn: avoid memleak
Simplify the code a bit, at the cost of potentially duplicating some
memory unneccessarily.
Fixes CID 1299641.
Diffstat (limited to 'src/nspawn')
-rw-r--r-- | src/nspawn/nspawn.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 4e41990176..322675222d 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -4065,7 +4065,7 @@ static int inner_child( NULL }; - char **env_use; + _cleanup_strv_free_ char **env_use = NULL; int r; assert(barrier); @@ -4173,16 +4173,9 @@ static int inner_child( return log_oom(); } - if (!strv_isempty(arg_setenv)) { - char **n; - - n = strv_env_merge(2, envp, arg_setenv); - if (!n) - return log_oom(); - - env_use = n; - } else - env_use = (char**) envp; + env_use = strv_env_merge(2, envp, arg_setenv); + if (!env_use) + return log_oom(); /* Let the parent know that we are ready and * wait until the parent is ready with the |