]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/execute: set_get_strv() does not transfer ownership of strings
authorMike Yuan <me@yhndnzj.com>
Sat, 12 Apr 2025 22:17:54 +0000 (00:17 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 13 Apr 2025 00:14:18 +0000 (09:14 +0900)
Prompted by #37090

src/core/dbus-execute.c
src/core/execute.c

index ea1c3df0465174d3052ea4bdf776c20df183f34b..2e79fdf276184a49c5bd421a5fd5bbf61fca6c6e 100644 (file)
@@ -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);
index b789a1b454b757df43fd6394b03d47813e841f3a..cca42583d1d65e90fc5ae377785e9121fd78ea26 100644 (file)
@@ -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) {