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

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



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


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