1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00

shared/exec-util: fix minor memleak

p was not freed on error.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-02-16 16:00:17 +01:00
parent 73c8cc7164
commit b230baaeb7

View File

@ -278,18 +278,12 @@ static int gather_environment_generate(int fd, void *arg) {
return r; return r;
STRV_FOREACH_PAIR(x, y, new) { STRV_FOREACH_PAIR(x, y, new) {
char *p;
if (!env_name_is_valid(*x)) { if (!env_name_is_valid(*x)) {
log_warning("Invalid variable assignment \"%s=...\", ignoring.", *x); log_warning("Invalid variable assignment \"%s=...\", ignoring.", *x);
continue; continue;
} }
p = strjoin(*x, "=", *y); r = strv_env_assign(env, *x, *y);
if (!p)
return -ENOMEM;
r = strv_env_replace(env, p);
if (r < 0) if (r < 0)
return r; return r;
@ -297,7 +291,7 @@ static int gather_environment_generate(int fd, void *arg) {
return -errno; return -errno;
} }
return r; return 0;
} }
static int gather_environment_collect(int fd, void *arg) { static int gather_environment_collect(int fd, void *arg) {