From: AntonMoryakov Date: Thu, 16 Jan 2025 16:24:20 +0000 (+0300) Subject: setpriv.c: fix memory leak in parse_groups function X-Git-Tag: v2.42-start~81^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f5bd825b9c187000d621f65af08b23a945a6cad8;p=thirdparty%2Futil-linux.git 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 --- diff --git a/sys-utils/setpriv.c b/sys-utils/setpriv.c index 87299a10d..907845545 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)