[libvirt] [PATCH sandbox 7/9] Fix leak of file handle in libvirt-sandbox-init-qemu

Daniel P. Berrange berrange at redhat.com
Thu Aug 15 15:36:45 UTC 2013


From: "Daniel P. Berrange" <berrange at redhat.com>

The 'FILE *' handle used to read /proc/cmdline was not
closed in all codepaths. This caused coverity to identify
a resource leak.

Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
---
 libvirt-sandbox/libvirt-sandbox-init-qemu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libvirt-sandbox/libvirt-sandbox-init-qemu.c b/libvirt-sandbox/libvirt-sandbox-init-qemu.c
index 44f5de0..998bd02 100644
--- a/libvirt-sandbox/libvirt-sandbox-init-qemu.c
+++ b/libvirt-sandbox/libvirt-sandbox-init-qemu.c
@@ -557,8 +557,9 @@ static void set_debug(void)
     if (fp && fgets(line, sizeof line, fp)) {
         if (strstr(line, "debug"))
             debug=1;
-        fclose(fp);
     }
+    if (fp)
+        fclose(fp);
     if (umount("/proc") < 0) {
         fprintf(stderr, "libvirt-sandbox-init-qemu: %s: cannot unmount /proc: %s\n",
                 __func__, strerror(errno));
-- 
1.8.3.1




More information about the libvir-list mailing list