Re: [PATCH V1 3/5] tests: fix resource leak

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

 



On 2012年05月04日 19:54, Stefan Berger wrote:
Error: RESOURCE_LEAK:
/libvirt/tests/qemuxml2argvtest.c:47:
alloc_arg: Calling allocation function "virAlloc" on "ret".
/libvirt/src/util/memory.c:101:
alloc_fn: Storage is returned from allocation function "calloc".
/libvirt/src/util/memory.c:101:
var_assign: Assigning: "*((void **)ptrptr)" = "calloc(1UL, size)".
/libvirt/tests/qemuxml2argvtest.c:54:
leaked_storage: Variable "ret" going out of scope leaks the storage it points to.

---
  tests/qemuxml2argvtest.c |    4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

Index: libvirt-acl/tests/qemuxml2argvtest.c
===================================================================
--- libvirt-acl.orig/tests/qemuxml2argvtest.c
+++ libvirt-acl/tests/qemuxml2argvtest.c
@@ -50,8 +50,10 @@ fakeSecretLookupByUsage(virConnectPtr co
      ret->magic = VIR_SECRET_MAGIC;
      ret->refs = 1;
      ret->usageID = strdup(usageID);
-    if (!ret->usageID)
+    if (!ret->usageID) {
+        VIR_FREE(ret);
          return NULL;
+    }
      ret->conn = conn;
      conn->refs++;
      return ret;

ACK

Osier

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