lib/: Chain free(strzero(s))

This reduces the repetition of the argument, which could be error-prone.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-08-12 02:21:01 +02:00
committed by Serge Hallyn
parent dab8de8a72
commit f5806e0511
6 changed files with 16 additions and 24 deletions

View File

@@ -83,10 +83,9 @@ void
gr_free(/*@only@*/struct group *grent)
{
free (grent->gr_name);
if (NULL != grent->gr_passwd) {
strzero (grent->gr_passwd);
free (grent->gr_passwd);
}
if (NULL != grent->gr_passwd)
free(strzero(grent->gr_passwd));
gr_free_members(grent);
free (grent);
}

View File

@@ -112,12 +112,9 @@ static /*@observer@*//*@null@*/const char *password_check (
} else if (strstr (wrapped, newmono) != NULL) {
msg = _("rotated");
}
strzero (newmono);
strzero (oldmono);
strzero (wrapped);
free (newmono);
free (oldmono);
free (wrapped);
free(strzero(newmono));
free(strzero(oldmono));
free(strzero(wrapped));
return msg;
}

View File

@@ -98,8 +98,7 @@ static int ni_conv (int num_msg,
failed_conversation:
for (count=0; count < num_msg; count++) {
if (NULL != responses[count].resp) {
strzero(responses[count].resp);
free(responses[count].resp);
free(strzero(responses[count].resp));
responses[count].resp = NULL;
}
}

View File

@@ -76,10 +76,9 @@ pw_free(/*@only@*/struct passwd *pwent)
{
if (pwent != NULL) {
free (pwent->pw_name);
if (pwent->pw_passwd) {
strzero (pwent->pw_passwd);
free (pwent->pw_passwd);
}
if (pwent->pw_passwd)
free(strzero(pwent->pw_passwd));
free (pwent->pw_gecos);
free (pwent->pw_dir);
free (pwent->pw_shell);

View File

@@ -132,10 +132,9 @@ sgr_free(/*@only@*/struct sgrp *sgent)
{
size_t i;
free (sgent->sg_name);
if (NULL != sgent->sg_passwd) {
strzero (sgent->sg_passwd);
free (sgent->sg_passwd);
}
if (NULL != sgent->sg_passwd)
free(strzero(sgent->sg_passwd));
for (i = 0; NULL != sgent->sg_adm[i]; i++) {
free (sgent->sg_adm[i]);
}

View File

@@ -62,10 +62,9 @@ spw_free(/*@only@*/struct spwd *spent)
{
if (spent != NULL) {
free (spent->sp_namp);
if (NULL != spent->sp_pwdp) {
strzero (spent->sp_pwdp);
free (spent->sp_pwdp);
}
if (NULL != spent->sp_pwdp)
free(strzero(spent->sp_pwdp));
free (spent);
}
}