[PATCH 6/7] Coverity: Fix resource leak in nodeinfo.c

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

 



Error: RESOURCE_LEAK:
/builddir/build/BUILD/libvirt-0.9.10/src/nodeinfo.c:629: alloc_fn: Calling allocation function "fopen".
/builddir/build/BUILD/libvirt-0.9.10/src/nodeinfo.c:629: var_assign: Assigning: "cpuinfo" =  storage returned from "fopen("/proc/cpuinfo", "r")".
/builddir/build/BUILD/libvirt-0.9.10/src/nodeinfo.c:638: leaked_storage: Variable "cpuinfo" going out of scope leaks the storage it points to.
---
 src/nodeinfo.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index e842474..4072da2 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -636,6 +636,7 @@ int nodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED, virNodeInfoPtr nodeinfo) {
     }
 
     if (virAsprintf(&sysfs_cpuinfo, CPU_SYS_PATH) < 0) {
+        VIR_FORCE_FCLOSE(cpuinfo);
         virReportOOMError();
         return -1;
     }
-- 
1.7.7.3

--
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]