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(a)redhat.com>
---
tools/nss/libvirt_nss.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
index 89f1f3fdac..8fe5a6d1cf 100644
--- a/tools/nss/libvirt_nss.c
+++ b/tools/nss/libvirt_nss.c
@@ -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;
}
--
2.21.0