[Libosinfo] [PATCH 4/8] test-isodetect: Fix leak when loading ISO data

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


The string returned by g_data_input_stream_read_line() must be freed
when no longer needed.

This fixes:
==12890== 199,410 bytes in 6,710 blocks are definitely lost in loss record 2,166 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 0x646F9AE: g_data_input_stream_read_line (in /usr/lib64/libgio-2.0.so.0.4600.1)
==12890==    by 0x402806: load_iso (test-isodetect.c:135)
==12890==    by 0x4029B1: load_distro (test-isodetect.c:205)
==12890==    by 0x402B28: load_distros (test-isodetect.c:252)
==12890==    by 0x402C51: load_isos (test-isodetect.c:283)
==12890==    by 0x403058: test_one (test-isodetect.c:331)
==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)
---
 test/test-isodetect.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/test/test-isodetect.c b/test/test-isodetect.c
index 912f79b..67b3b2e 100644
--- a/test/test-isodetect.c
+++ b/test/test-isodetect.c
@@ -156,6 +156,8 @@ static struct ISOInfo *load_iso(GFile *file, const gchar *shortid, const gchar *
 
         if (key != NULL && value != NULL && value[0] != '\0')
             osinfo_entity_set_param(OSINFO_ENTITY(info->media), key, value);
+
+        g_free(line);
     }
 
     if (vol_size > 0 && blk_size > 0)
-- 
2.5.0




More information about the Libosinfo mailing list