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

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



From: "Daniel P. Berrange" <berrange 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 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


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