From: Mike Yuan Date: Sat, 12 Apr 2025 22:17:54 +0000 (+0200) Subject: core/execute: set_get_strv() does not transfer ownership of strings X-Git-Tag: v258-rc1~830 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7065494e7e1b1b8fa94bb94053f28827d155bad6;p=thirdparty%2Fsystemd.git core/execute: set_get_strv() does not transfer ownership of strings Prompted by #37090 --- diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index ea1c3df0465..2e79fdf2761 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -440,7 +440,7 @@ static int property_get_restrict_filesystems( sd_bus_error *error) { ExecContext *c = ASSERT_PTR(userdata); - _cleanup_free_ char **l = NULL; + _cleanup_free_ char **l = NULL; /* Strings are owned by 'c->restrict_filesystems'! */ int r; assert(bus); diff --git a/src/core/execute.c b/src/core/execute.c index b789a1b454b..cca42583d1d 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -1979,19 +1979,17 @@ char** exec_context_get_address_families(const ExecContext *c) { } char** exec_context_get_restrict_filesystems(const ExecContext *c) { - _cleanup_strv_free_ char **l = NULL; - assert(c); #if HAVE_LIBBPF - l = set_get_strv(c->restrict_filesystems); + char **l = set_get_strv(c->restrict_filesystems); if (!l) return NULL; - strv_sort(l); + return strv_sort(l); +#else + return strv_new(NULL); #endif - - return l ? TAKE_PTR(l) : strv_new(NULL); } void exec_status_start(ExecStatus *s, pid_t pid, const dual_timestamp *ts) {