lib/gshadow.c: sgetsgent(): Remove superfluous condition

If n was 0, it doesn't hurt to set it again to 0;
and the list would be NULL, so it doesn't hurt free(3)ing it
and setting to NULL again either.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-12-05 21:20:59 -06:00
committed by Serge Hallyn
parent de4715d978
commit 712278add1
+10 -11
View File
@@ -75,7 +75,8 @@ void endsgent (void)
shadow = NULL;
}
/*@observer@*//*@null@*/struct sgrp *sgetsgent (const char *string)
/*@observer@*//*@null@*/struct sgrp *
sgetsgent(const char *string)
{
static char *sgrbuf = NULL;
static size_t sgrbuflen = 0;
@@ -115,16 +116,14 @@ void endsgent (void)
sgroup.sg_name = fields[0];
sgroup.sg_passwd = fields[1];
if (0 != nadmins) {
nadmins = 0;
free (admins);
admins = NULL;
}
if (0 != nmembers) {
nmembers = 0;
free (members);
members = NULL;
}
nadmins = 0;
free (admins);
admins = NULL;
nmembers = 0;
free (members);
members = NULL;
sgroup.sg_adm = build_list (fields[2], &admins, &nadmins);
sgroup.sg_mem = build_list (fields[3], &members, &nmembers);