diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-02-16 16:00:17 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-02-16 16:10:14 +0100 |
commit | b230baaeb76dd1f3b6c991257331fc816ee7827b (patch) | |
tree | b7685be617e10a76415f35425b6e0d3af37674ae /src/shared/exec-util.c | |
parent | test-env-util: add tests for the two new functions (diff) | |
download | systemd-b230baaeb76dd1f3b6c991257331fc816ee7827b.tar.xz systemd-b230baaeb76dd1f3b6c991257331fc816ee7827b.zip |
shared/exec-util: fix minor memleak
p was not freed on error.
Diffstat (limited to '')
-rw-r--r-- | src/shared/exec-util.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/shared/exec-util.c b/src/shared/exec-util.c index 6355ce8ce4..1557086079 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) { |