[libvirt-glib 2/4] test-gconfig: Fix various leaks

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

 



Running test-gconfig under valgrind reports a few leaks that this commit
fixes.
---
 tests/test-gconfig.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tests/test-gconfig.c b/tests/test-gconfig.c
index 0eec53e..de09c24 100644
--- a/tests/test-gconfig.c
+++ b/tests/test-gconfig.c
@@ -48,6 +48,7 @@ static void check_xml(GVirConfigDomain *domain, const char *reference_file)
     xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(domain));
     g_assert_cmpstr(xml, ==, reference_xml);
     g_free(xml);
+    g_free(reference_xml);
 }
 
 
@@ -224,6 +225,8 @@ static void test_domain_os(void)
     gvir_config_domain_set_os(domain, NULL);
     os = gvir_config_domain_get_os(domain);
     g_assert(os == NULL);
+
+    g_object_unref(G_OBJECT(domain));
 }
 
 
@@ -294,9 +297,13 @@ static void test_domain_cpu(void)
                                               NULL);
     topology = gvir_config_capabilities_cpu_get_topology(GVIR_CONFIG_CAPABILITIES_CPU(cpu));
     g_assert(topology == NULL);
+    g_object_unref(G_OBJECT(cpu));
+
     gvir_config_domain_set_cpu(domain, NULL);
     cpu = gvir_config_domain_get_cpu(domain);
     g_assert(cpu == NULL);
+
+    g_object_unref(G_OBJECT(domain));
 }
 
 
@@ -347,6 +354,7 @@ static void test_domain_device_disk(void)
     g_assert(gvir_config_domain_disk_driver_get_copy_on_read(driver));
     g_assert_cmpint(gvir_config_domain_disk_get_target_bus(disk), ==, GVIR_CONFIG_DOMAIN_DISK_BUS_IDE);
     g_assert_cmpstr(gvir_config_domain_disk_get_target_dev(disk), ==, "hda");
+    g_object_unref(G_OBJECT(driver));
 
     gvir_config_domain_disk_set_driver(disk, NULL);
     driver = gvir_config_domain_disk_get_driver(disk);
@@ -433,6 +441,7 @@ static void test_domain_device_input(void)
                                              GVIR_CONFIG_DOMAIN_INPUT_DEVICE_TABLET);
     gvir_config_domain_input_set_bus(input, GVIR_CONFIG_DOMAIN_INPUT_BUS_USB);
     gvir_config_domain_add_device(domain, GVIR_CONFIG_DOMAIN_DEVICE(input));
+    g_object_unref(G_OBJECT(input));
 
     check_xml(domain, "gconfig-domain-device-input.xml");
 
-- 
2.4.3

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