[Libosinfo] [PATCH 11/14] install-script: Fix OsinfoOs leaks

Christophe Fergeau cfergeau at redhat.com
Wed Jun 8 10:01:15 UTC 2016


The OsinfoOs instance returned by osinfo_media_get_os must be unref'ed
when no longer needed.

This fixes:

==29859== 3,926 (96 direct, 3,830 indirect) bytes in 1 blocks are definitely lost in loss record 2,286 of 2,295
==29859==    at 0x65E19D0: g_type_create_instance (gtype.c:1854
==29859==    by 0x65C36AA: g_object_new_internal (gobject.c:1781)
==29859==    by 0x65C55ED: g_object_new_valist (gobject.c:2040)
==29859==    by 0x65C58A0: g_object_new (gobject.c:1624)
==29859==    by 0x5339F69: osinfo_os_new (osinfo_os.c:201)
==29859==    by 0x5347FFD: osinfo_loader_get_os (osinfo_loader.c:464)
==29859==    by 0x534B439: osinfo_loader_os (osinfo_loader.c:1410)
==29859==    by 0x534BFB1: osinfo_loader_root (osinfo_loader.c:1599)
==29859==    by 0x534C399: osinfo_loader_process_xml (osinfo_loader.c:1680)
==29859==    by 0x534CFEE: osinfo_loader_process_file_reg_xml (osinfo_loader.c:1877)
==29859==    by 0x534DA1F: osinfo_loader_process_list (osinfo_loader.c:2160)
==29859==    by 0x534DCEA: osinfo_loader_process_path (osinfo_loader.c:2232)
==29859==    by 0x402310: test_script_file (test-install-script.c:146)
==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)
==29859==-
==29859== 3,926 (96 direct, 3,830 indirect) bytes in 1 blocks are definitely lost in loss record 2,287 of 2,295
==29859==    at 0x65E19D0: g_type_create_instance (gtype.c:1854)
==29859==    by 0x65C36AA: g_object_new_internal (gobject.c:1781)
==29859==    by 0x65C55ED: g_object_new_valist (gobject.c:2040)
==29859==    by 0x65C58A0: g_object_new (gobject.c:1624)
==29859==    by 0x5339F69: osinfo_os_new (osinfo_os.c:201)
==29859==    by 0x5347FFD: osinfo_loader_get_os (osinfo_loader.c:464)
==29859==    by 0x534B439: osinfo_loader_os (osinfo_loader.c:1410)
==29859==    by 0x534BFB1: osinfo_loader_root (osinfo_loader.c:1599)
==29859==    by 0x534C399: osinfo_loader_process_xml (osinfo_loader.c:1680)
==29859==    by 0x534CFEE: osinfo_loader_process_file_reg_xml (osinfo_loader.c:1877)
==29859==    by 0x534DA1F: osinfo_loader_process_list (osinfo_loader.c:2160)
==29859==    by 0x534DCEA: osinfo_loader_process_path (osinfo_loader.c:2232)
==29859==    by 0x402626: test_script_data (test-install-script.c:199)
==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)
---
 osinfo/osinfo_install_script.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
index 23db364..2465771 100644
--- a/osinfo/osinfo_install_script.c
+++ b/osinfo/osinfo_install_script.c
@@ -1223,6 +1223,8 @@ void osinfo_install_script_generate_for_media_async(OsinfoInstallScript *script,
                                                 cancellable,
                                                 callback,
                                                 user_data);
+
+    g_object_unref(os);
 }
 
 static void osinfo_install_script_generate_for_media_done(GObject *src,
@@ -1644,6 +1646,7 @@ gchar *osinfo_install_script_generate_command_line_for_media(OsinfoInstallScript
             g_prefix_error(&error, "%s", _("Failed to apply script template: "));
         }
     }
+    g_object_unref(os);
 
     return output;
 }
-- 
2.7.4




More information about the Libosinfo mailing list