]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: fix resource leak
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Fri, 4 May 2012 14:42:09 +0000 (10:42 -0400)
committerCole Robinson <crobinso@redhat.com>
Thu, 14 Jun 2012 15:16:32 +0000 (11:16 -0400)
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.

(cherry picked from commit a01e67217c5e0a3fcba260e44c15b0fa94b47782)

tests/qemuxml2argvtest.c

index fdbe95ac8fd703a08bfd274b07a06f3975d35fda..3529c3764070df6248f232451a126d1ac30848dd 100644 (file)
@@ -50,8 +50,10 @@ fakeSecretLookupByUsage(virConnectPtr conn,
     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;