]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: fix some resource leaks
authorPavel Hrdina <phrdina@redhat.com>
Sun, 9 Apr 2017 11:28:07 +0000 (13:28 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Tue, 11 Apr 2017 11:23:01 +0000 (13:23 +0200)
Found by running valgrind for these tests.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
tests/commandtest.c
tests/domaincapstest.c
tests/fchosttest.c
tests/vircgroupmock.c

index 80f10f88fc397ec407b9c391a138ab6391568112..1f6f16bcde73936ede89bcbc42ad7e3d0971d0b2 100644 (file)
@@ -1093,6 +1093,9 @@ static int test25(const void *unused ATTRIBUTE_UNUSED)
         virCommandPtr cmd = virCommandNew("some/nonexistent/binary");
 
         rv = virCommandExec(cmd);
+
+        virCommandFree(cmd);
+
         if (safewrite(pipeFD[1], &rv, sizeof(rv)) < 0)
             fprintf(stderr, "Unable to write to pipe\n");
         _exit(EXIT_FAILURE);
index f871197c25fe6ad177750dca119a42de90679022..edf06c4e8ef5ba1a2bb61efeb95a483cef8caac4 100644 (file)
@@ -534,6 +534,8 @@ mymain(void)
                  "/usr/bin/qemu-system-s390x", NULL,
                  "s390x", VIR_DOMAIN_VIRT_KVM);
 
+    virObjectUnref(cfg);
+
 #endif /* WITH_QEMU */
 
 #if WITH_LIBXL
index ac4e92910d06e6c2f2a5c51f8df493298db69af3..3ee19129260936485905df8a25e425d90771afba 100644 (file)
@@ -315,6 +315,7 @@ manageVHBAByStoragePool(const void *data)
         ignore_value(virStoragePoolDestroy(pool));
         goto cleanup;
     }
+    virNodeDeviceFree(dev);
 
     if (virStoragePoolDestroy(pool) < 0)
         goto cleanup;
@@ -322,6 +323,7 @@ manageVHBAByStoragePool(const void *data)
     if ((dev = virNodeDeviceLookupByName(conn, expect_hostname))) {
         VIR_DEBUG("Found expected_hostname '%s' after destroy",
                   expect_hostname);
+        virNodeDeviceFree(dev);
         goto cleanup;
     }
 
index ce6fd46266d9df7606f82cc2cd9b74d58a04f7c6..9eb989ad7e644a76a7711e993a11c2e5d771be60 100644 (file)
@@ -429,8 +429,10 @@ static void init_sysfs(void)
             abort();                                                   \
         if (make_controller(path, 0755) < 0) {                         \
             fprintf(stderr, "Cannot initialize %s\n", path);           \
+            free(path);                                                \
             abort();                                                   \
         }                                                              \
+        free(path);                                                    \
     } while (0)
 
     MAKE_CONTROLLER("cpu");