[PATCH 2/5] nss: Drop needless free() in gethostbyname3()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux