From 3a5c91e6fc4ba64d5e922a7f3b5d1b5ed38ba3f7 Mon Sep 17 00:00:00 2001 From: Ritika Chopra Date: Tue, 6 Jan 2026 10:13:14 -0700 Subject: T8083: Address memory leaks in the related code leg --- nss_tacplus.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nss_tacplus.c b/nss_tacplus.c index 5492611..e717610 100644 --- a/nss_tacplus.c +++ b/nss_tacplus.c @@ -1026,6 +1026,8 @@ fixup_gr_mem(const char *grnam, const char **gr_in, char *buf, total_chars += (long long)strlen(tok) + 1; tok = strtok_r(NULL, ",", &saved); } + free(mapnames); + mapnames = NULL; } else { nadded++; @@ -1056,11 +1058,16 @@ fixup_gr_mem(const char *grnam, const char **gr_in, char *buf, tok = strtok_r(mapnames, ",", &saved); while (tok) { gr_mem[midx] = mem; - if(copyuser(&mem, tok, &len, err)) + if(copyuser(&mem, tok, &len, err)) { + free(mapnames); + mapnames = NULL; goto done; + } midx++; tok = strtok_r(NULL, ",", &saved); } + free(mapnames); + mapnames = NULL; } else { /* just copy what was returned to the buffer */ gr_mem[midx] = mem; -- cgit v1.2.3