mirror of https://gitee.com/openkylin/libvirt.git
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:
parent
b62ef64216
commit
e39100ac92
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue