Skip to content

Commit 7065494

Browse files
YHNdnzjyuwata
authored andcommitted
core/execute: set_get_strv() does not transfer ownership of strings
Prompted by systemd#37090
1 parent 5935d74 commit 7065494

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/core/dbus-execute.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ static int property_get_restrict_filesystems(
440440
sd_bus_error *error) {
441441

442442
ExecContext *c = ASSERT_PTR(userdata);
443-
_cleanup_free_ char **l = NULL;
443+
_cleanup_free_ char **l = NULL; /* Strings are owned by 'c->restrict_filesystems'! */
444444
int r;
445445

446446
assert(bus);

src/core/execute.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,19 +1979,17 @@ char** exec_context_get_address_families(const ExecContext *c) {
19791979
}
19801980

19811981
char** exec_context_get_restrict_filesystems(const ExecContext *c) {
1982-
_cleanup_strv_free_ char **l = NULL;
1983-
19841982
assert(c);
19851983

19861984
#if HAVE_LIBBPF
1987-
l = set_get_strv(c->restrict_filesystems);
1985+
char **l = set_get_strv(c->restrict_filesystems);
19881986
if (!l)
19891987
return NULL;
19901988

1991-
strv_sort(l);
1989+
return strv_sort(l);
1990+
#else
1991+
return strv_new(NULL);
19921992
#endif
1993-
1994-
return l ? TAKE_PTR(l) : strv_new(NULL);
19951993
}
19961994

19971995
void exec_status_start(ExecStatus *s, pid_t pid, const dual_timestamp *ts) {

0 commit comments

Comments
 (0)