From b7eefa1996f33f29b32bc9e5f20f4e70fa22a14a Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Thu, 21 Nov 2024 00:53:20 +0000 Subject: cgroup-util: fix memory leak on error CID#1565824 Follow-up for f6793bbcf0e3f0a6daa77add96183b88d5ec2117 --- src/basic/cgroup-util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/basic') diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index 5370090f00..8b1e051d56 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -799,7 +799,7 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **ret_path) { continue; } - char *path = strdup(e + 1); + _cleanup_free_ char *path = strdup(e + 1); if (!path) return -ENOMEM; @@ -812,7 +812,7 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **ret_path) { if (e) *e = 0; - *ret_path = path; + *ret_path = TAKE_PTR(path); return 0; } } -- cgit v1.2.3