[PATCH 07/14] test-install-script: Fix various small leaks

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

 



The value returned by osinfo_install_script_generate_for_media_finish()
was not freed in several codepaths, and the mainloop was not destroyed when
no longer needed. Data read with g_file_load_contents was also not freed
when no longer used.

This fixes:
==12193== 528 bytes in 1 blocks are definitely lost in loss record 2,279 of 2,310
==12193==    at 0x4C2BBAD: malloc (vg_replace_malloc.c:299)
==12193==    by 0x5F6D459: xmlStrndup (xmlstring.c:45)
==12193==    by 0x556EF95: xsltSaveResultToString (xsltutils.c:1780)
==12193==    by 0x53345C2: osinfo_install_script_apply_xslt (osinfo_install_script.c:824)
==12193==    by 0x53346EC: osinfo_install_script_apply_template (osinfo_install_script.c:853)
==12193==    by 0x5334A7A: osinfo_install_script_generate_async_common (osinfo_install_script.c:942)
==12193==    by 0x5335170: osinfo_install_script_generate_for_media_async (osinfo_install_script.c:1216)
==12193==    by 0x40298A: test_script_data (test-install-script.c:212)
==12193==    by 0x5117535: tcase_run_tfun_nofork.isra.9 (check_run.c:390)
==12193==    by 0x51178EB: srunner_iterate_tcase_tfuns (check_run.c:231)
==12193==    by 0x51178EB: srunner_run_tcase (check_run.c:373)
==12193==    by 0x51178EB: srunner_iterate_suites (check_run.c:195)
==12193==    by 0x51178EB: srunner_run (check_run.c:782)
==12193==    by 0x401F82: main (test-install-script.c:345)

==12193== 16 bytes in 1 blocks are definitely lost in loss record 772 of 2,310
==12193==    at 0x4C2DA60: calloc (vg_replace_malloc.c:711)
==12193==    by 0x684FEB0: g_malloc0 (gmem.c:124)
==12193==    by 0x684ABF1: g_main_loop_new (gmain.c:3929)
==12193==    by 0x402373: test_script_datamap (test-install-script.c:284)
==12193==    by 0x5117535: tcase_run_tfun_nofork.isra.9 (check_run.c:390)
==12193==    by 0x51178EB: srunner_iterate_tcase_tfuns (check_run.c:231)
==12193==    by 0x51178EB: srunner_run_tcase (check_run.c:373)
==12193==    by 0x51178EB: srunner_iterate_suites (check_run.c:195)
==12193==    by 0x51178EB: srunner_run (check_run.c:782)
==12193==    by 0x401F82: main (test-install-script.c:345)

==29859== 16,384 bytes in 1 blocks are definitely lost in loss record 2,295 of 2,295
==29859==    at 0x4C2BAEE: malloc (vg_replace_malloc.c:298)
==29859==    by 0x4C2DCA1: realloc (vg_replace_malloc.c:785)
==29859==    by 0x684FF1F: g_realloc (gmem.c:159)
==29859==    by 0x681DE68: g_array_maybe_expand (garray.c:779)
==29859==    by 0x681E783: g_array_set_size (garray.c:555)
==29859==    by 0x681F328: g_byte_array_set_size (garray.c:1752)
==29859==    by 0x62775AE: g_file_load_contents (gfile.c:6748)
==29859==    by 0x4025E9: test_script_data (test-install-script.c:195)
==29859==    by 0x5117535: tcase_run_tfun_nofork.isra.9 (check_run.c:390)
==29859==    by 0x51178EB: srunner_iterate_tcase_tfuns (check_run.c:231)
==29859==    by 0x51178EB: srunner_run_tcase (check_run.c:373)
==29859==    by 0x51178EB: srunner_iterate_suites (check_run.c:195)
==29859==    by 0x51178EB: srunner_run (check_run.c:782)
==29859==    by 0x40303D: main (test-install-script.c:349)
---
 test/test-install-script.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/test/test-install-script.c b/test/test-install-script.c
index 338fc3b..d62e36d 100644
--- a/test/test-install-script.c
+++ b/test/test-install-script.c
@@ -170,6 +170,7 @@ START_TEST(test_script_file)
     fail_unless(strcmp(actualData, expectData) == 0, "Actual '%s' match expect '%s'",
                 actualData, expectData);
 
+    g_free(actualData);
     g_object_unref(media);
     g_object_unref(db);
     g_object_unref(config);
@@ -222,10 +223,13 @@ START_TEST(test_script_data)
     unlink(BUILDDIR "/test/install-script-actual.txt");
     fail_unless(error == NULL, error ? error->message : "none");
 
+    g_free(data);
+    g_free(actualData);
     g_object_unref(media);
     g_object_unref(db);
     g_object_unref(config);
     g_object_unref(script);
+    g_main_loop_unref(loop);
 }
 END_TEST
 
@@ -300,9 +304,11 @@ START_TEST(test_script_datamap)
     fail_unless(strcmp(actualData, expectData2) == 0, "Actual '%s' match expect '%s'",
                 actualData, expectData2);
 
+    g_free(actualData);
     g_object_unref(db);
     g_object_unref(os);
     g_object_unref(config);
+    g_main_loop_unref(loop);
 }
 END_TEST
 
-- 
2.7.4

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux