]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: fix some resource leaks
authorPavel Hrdina <phrdina@redhat.com>
Sun, 9 Apr 2017 11:28:07 +0000 (13:28 +0200)
committerCole Robinson <crobinso@redhat.com>
Wed, 10 May 2017 19:21:38 +0000 (15:21 -0400)
Found by running valgrind for these tests.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 9005a64b5cd2a064418572ec295532efb3df2798)

tests/commandtest.c
tests/domaincapstest.c
tests/fchosttest.c
tests/vircgroupmock.c

index bfbf6a42f611e04743d6d1e06c9ba36aeec3d367..e86396052f67a89a0acfae798818edbcba346ca0 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 02cadf8ea32757d7b031afcca1d643a3aee09acf..9422a03e2608fd2d25be16e10d6807aa1e24e8d3 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 dc6b9af9884e7e3b5173f503d454d1887558498a..601d4cdabdd63928fa8d31b6399a89e279d62beb 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");