From: Zbigniew Jędrzejewski-Szmek Date: Tue, 16 Feb 2021 15:00:17 +0000 (+0100) Subject: shared/exec-util: fix minor memleak X-Git-Tag: v248-rc1~92^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b230baaeb76dd1f3b6c991257331fc816ee7827b;p=thirdparty%2Fsystemd.git shared/exec-util: fix minor memleak p was not freed on error. --- diff --git a/src/shared/exec-util.c b/src/shared/exec-util.c index 6355ce8ce42..1557086079e 100644 --- a/src/shared/exec-util.c +++ b/src/shared/exec-util.c @@ -278,18 +278,12 @@ static int gather_environment_generate(int fd, void *arg) { return r; STRV_FOREACH_PAIR(x, y, new) { - char *p; - if (!env_name_is_valid(*x)) { log_warning("Invalid variable assignment \"%s=...\", ignoring.", *x); continue; } - p = strjoin(*x, "=", *y); - if (!p) - return -ENOMEM; - - r = strv_env_replace(env, p); + r = strv_env_assign(env, *x, *y); if (r < 0) return r; @@ -297,7 +291,7 @@ static int gather_environment_generate(int fd, void *arg) { return -errno; } - return r; + return 0; } static int gather_environment_collect(int fd, void *arg) {