From: David Tardon Date: Fri, 21 Apr 2023 12:24:26 +0000 (+0200) Subject: env-util: use _cleanup_ in strv_env_delete() X-Git-Tag: v254-rc1~603^2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=480a7919bce9d60b78532ff51fcdb82529df0af8;p=thirdparty%2Fsystemd.git env-util: use _cleanup_ in strv_env_delete() --- diff --git a/src/basic/env-util.c b/src/basic/env-util.c index 41fad1d1b9e..848b727a8f7 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -266,7 +266,7 @@ static bool env_entry_has_name(const char *entry, const char *name) { char **strv_env_delete(char **x, size_t n_lists, ...) { size_t n, i = 0; - char **r; + _cleanup_strv_free_ char **r = NULL; va_list ap; /* Deletes every entry from x that is mentioned in the other @@ -291,10 +291,8 @@ char **strv_env_delete(char **x, size_t n_lists, ...) { va_end(ap); r[i] = strdup(*k); - if (!r[i]) { - strv_free(r); + if (!r[i]) return NULL; - } i++; continue; @@ -307,7 +305,7 @@ char **strv_env_delete(char **x, size_t n_lists, ...) { assert(i <= n); - return r; + return TAKE_PTR(r); } char **strv_env_unset(char **l, const char *p) {