From f5bd825b9c187000d621f65af08b23a945a6cad8 Mon Sep 17 00:00:00 2001
From: AntonMoryakov <ant.v.moryakov@gmail.com>
Date: Thu, 16 Jan 2025 19:24:20 +0300
Subject: [PATCH] setpriv.c: fix memory leak in parse_groups function

The static analyzer flagged a memory leak in the parse_groups function.
The memory allocated for 'buf' (via xstrdup) was not freed at the end
of the function, leading to a memory leak.

Changes:
- Added free(buf) at the end of the function to release allocated memory.

Triggers found by static analyzer Svace.

Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
Reference:https://github.com/util-linux/util-linux/commit/f5bd825b9c187000d621f65af08b23a945a6cad8
Conflict:NA
---
 sys-utils/setpriv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys-utils/setpriv.c b/sys-utils/setpriv.c
index 87299a10..90784554 100644
--- a/sys-utils/setpriv.c
+++ b/sys-utils/setpriv.c
@@ -448,7 +448,7 @@ static void parse_groups(struct privctx *opts, const char *str)
 	while ((c = strsep(&groups, ",")))
 		opts->groups[i++] = get_group(c, _("Invalid supplementary group id"));
 
-	free(groups);
+	free(buf);
 }
 
 static void parse_pdeathsig(struct privctx *opts, const char *str)
-- 
2.33.0

