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

[libvirt] [PATCH 1/4] libvirtd: avoid memory leak on OOM



Detected by Coverity; only strikes on OOM so not serious.

* daemon/libvirtd.c (daemonPidFilePath): Plug leak.
---
 daemon/libvirtd.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 60ee705..06d2077 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -310,8 +310,10 @@ daemonPidFilePath(bool privileged,
         if (!(userdir = virGetUserDirectory(geteuid())))
             goto error;

-        if (virAsprintf(pidfile, "%s/.libvirt/libvirtd.pid", userdir) < 0)
+        if (virAsprintf(pidfile, "%s/.libvirt/libvirtd.pid", userdir) < 0) {
+            VIR_FREE(userdir);
             goto no_memory;
+        }

         VIR_FREE(userdir);
     }
-- 
1.7.4.4


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