[Libosinfo] [PATCH 1/8] db: Fix leak of 'variants' GList

Christophe Fergeau cfergeau at redhat.com
Thu Nov 5 16:20:39 UTC 2015


The GList returned by osinfo_entity_get_param_value_list() must be freed
when no longer needed.

This fixes:
==12890== 2,112 bytes in 88 blocks are definitely lost in loss record 2,139 of 2,169
==12890==    at 0x4C28C50: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12890==    by 0x6A514D8: g_malloc (in /usr/lib64/libglib-2.0.so.0.4600.1)
==12890==    by 0x6A68622: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.4600.1)
==12890==    by 0x6A47EA9: g_list_copy_deep (in /usr/lib64/libglib-2.0.so.0.4600.1)
==12890==    by 0x55400A8: osinfo_entity_get_param_value_list (osinfo_entity.c:424)
==12890==    by 0x555A58F: fill_media (osinfo_db.c:654)
==12890==    by 0x555A8C4: osinfo_db_identify_media (osinfo_db.c:709)
==12890==    by 0x4030C5: test_one (test-isodetect.c:338)
==12890==    by 0x4033B8: test_windows (test-isodetect.c:387)
==12890==    by 0x532B78A: tcase_run_tfun_nofork.isra.9 (check_run.c:390)
==12890==    by 0x532BB7C: srunner_iterate_tcase_tfuns (check_run.c:231)
==12890==    by 0x532BB7C: srunner_run_tcase (check_run.c:373)
==12890==    by 0x532BB7C: srunner_iterate_suites (check_run.c:195)
==12890==    by 0x532BB7C: srunner_run (check_run.c:782)
==12890==    by 0x4037B9: main (test-isodetect.c:496)
=
---
 osinfo/osinfo_db.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
index 9542d6e..4eeb440 100644
--- a/osinfo/osinfo_db.c
+++ b/osinfo/osinfo_db.c
@@ -656,6 +656,7 @@ static void fill_media(OsinfoDb *db, OsinfoMedia *media,
         osinfo_entity_add_param(OSINFO_ENTITY(media),
                                 "variant",
                                 (gchar *) node->data);
+    g_list_free (variants);
     kernel_path = osinfo_media_get_kernel_path(matched_media);
     if (kernel_path != NULL)
         g_object_set(G_OBJECT(media), "kernel_path", kernel_path, NULL);
-- 
2.5.0




More information about the Libosinfo mailing list