]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
setpriv.c: fix memory leak in parse_groups function
authorAntonMoryakov <ant.v.moryakov@gmail.com>
Thu, 16 Jan 2025 16:24:20 +0000 (19:24 +0300)
committerAntonMoryakov <ant.v.moryakov@gmail.com>
Thu, 16 Jan 2025 16:24:35 +0000 (19:24 +0300)
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>
sys-utils/setpriv.c

index 87299a10d124687168ad1a5c56d3823aa7850732..90784554539af2ff28014830ec49c6e2b46400b9 100644 (file)
@@ -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)