nss: Drop needless free() in gethostbyname3()

The findLease() function allocates @addr array iff no error
occurred and at least one satisfactory record was found.
Therefore, there is no need to call free() if findLease() failed,
or did not find any records as addr == NULL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Michal Privoznik 2019-09-28 21:24:53 +02:00
parent b62ef64216
commit e39100ac92
1 changed files with 0 additions and 3 deletions

View File

@ -267,7 +267,6 @@ NSS_NAME(gethostbyname3)(const char *name, int af, struct hostent *result,
af = AF_INET;
if ((r = findLease(name, af, &addr, &naddr, &found, errnop)) < 0) {
free(addr);
/* Error occurred. Return immediately. */
if (*errnop == EAGAIN) {
*herrnop = TRY_AGAIN;
@ -282,13 +281,11 @@ NSS_NAME(gethostbyname3)(const char *name, int af, struct hostent *result,
/* NOT found */
*errnop = ESRCH;
*herrnop = HOST_NOT_FOUND;
free(addr);
return NSS_STATUS_NOTFOUND;
} else if (!naddr) {
/* Found, but no data */
*errnop = ENXIO;
*herrnop = NO_DATA;
free(addr);
return NSS_STATUS_UNAVAIL;
}