[libvirt PATCH 2/2] nss: findLease: do not leak path

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

 



We still check for realloc's return value in the nss module.

Free the path in case it fails before jumping to cleanup.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 tools/nss/libvirt_nss.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
index b021efc3c9..87a731da79 100644
--- a/tools/nss/libvirt_nss.c
+++ b/tools/nss/libvirt_nss.c
@@ -138,8 +138,10 @@ findLease(const char *name,
                 goto cleanup;
 
             tmpLease = realloc(leaseFiles, sizeof(char *) * (nleaseFiles + 1));
-            if (!tmpLease)
+            if (!tmpLease) {
+                free(path);
                 goto cleanup;
+            }
             leaseFiles = tmpLease;
             leaseFiles[nleaseFiles++] = path;
 #if defined(LIBVIRT_NSS_GUEST)
-- 
2.29.2




[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