diff options
author | David Tardon <dtardon@redhat.com> | 2023-04-21 14:40:54 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2023-04-27 21:42:38 +0200 |
commit | 93eceb59e65871fa7e85baff2d69a38b610af913 (patch) | |
tree | 90be8bf9490fd33ecd912db11065edf19b7dda07 /src/basic/env-util.c | |
parent | env-util: use _cleanup_ in replace_env_argv() (diff) | |
download | systemd-93eceb59e65871fa7e85baff2d69a38b610af913.tar.xz systemd-93eceb59e65871fa7e85baff2d69a38b610af913.zip |
env-util: use more _cleanup_ in replace_env_argv()
Diffstat (limited to 'src/basic/env-util.c')
-rw-r--r-- | src/basic/env-util.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/basic/env-util.c b/src/basic/env-util.c index 03b4547cf3..5a933d7f08 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -746,7 +746,8 @@ char **replace_env_argv(char **argv, char **env) { /* If $FOO appears as single word, replace it by the split up variable */ if ((*i)[0] == '$' && !IN_SET((*i)[1], '{', '$')) { char *e; - char **w, **m = NULL; + char **w; + _cleanup_strv_free_ char **m = NULL; size_t q; e = strv_env_get(env, *i+1); @@ -758,8 +759,7 @@ char **replace_env_argv(char **argv, char **env) { ret[k] = NULL; return NULL; } - } else - m = NULL; + } q = strv_length(m); l = l + q - 1; @@ -767,14 +767,13 @@ char **replace_env_argv(char **argv, char **env) { w = reallocarray(ret, l + 1, sizeof(char *)); if (!w) { ret[k] = NULL; - strv_free(m); return NULL; } ret = w; if (m) { memcpy(ret + k, m, q * sizeof(char*)); - free(m); + m = mfree(m); } k += q; |