Valgrind was complaining about a memory leak in this function.  From
looking at similar code in libosinfo itself, it appears we ought to be
unrefing a lot more references here.

This error started happening after the new 'test-phony-win2k25.sh' was
added, but it seems to be unrelated to the test itself and must have
been a pre-existing problem that was exposed by the test.

  ==2959521==
  ==2959521== HEAP SUMMARY:
  ==2959521==     in use at exit: 43,662,865 bytes in 1,194,159 blocks
  ==2959521==   total heap usage: 3,898,497 allocs, 2,704,338 frees, 
2,609,865,939 bytes allocated
  ==2959521==
  ==2959521== 353 (40 direct, 313 indirect) bytes in 1 blocks are definitely 
lost in loss record 2,661 of 3,422
  ==2959521==    at 0x52BFAEC: g_type_create_instance (gtype.c:1929)
  ==2959521==    by 0x52A48B3: g_object_new_internal.part.0 (gobject.c:2606)
  ==2959521==    by 0x52A5EFD: g_object_new_with_properties (gobject.c:2603)
  ==2959521==    by 0x52A6F30: g_object_new (gobject.c:2415)
  ==2959521==    by 0x121A52: v2v_osinfo_os_find_os_by_short_id 
(libosinfo-c.c:166)
  ==2959521==    by 0x2DEE12: caml_c_call (in 
/home/rjones/d/virt-v2v/v2v/virt-v2v)
  ==2959521==    by 0x6F4D7BF: ???
  ==2959521==    by 0x6F5543F: ???
  ==2959521==
  ==2959521== LEAK SUMMARY:
  ==2959521==    definitely lost: 40 bytes in 1 blocks
  ==2959521==    indirectly lost: 87 bytes in 5 blocks
  ==2959521==      possibly lost: 0 bytes in 0 blocks
  ==2959521==    still reachable: 1,976,140 bytes in 98 blocks
  ==2959521==         suppressed: 35,544,294 bytes in 1,133,259 blocks
  ==2959521== Reachable blocks (those to which a pointer was found) are not 
shown.
  ==2959521== To see them, rerun with: --leak-check=full --show-leak-kinds=all
  ==2959521==
  ==2959521== For lists of detected and suppressed errors, rerun with: -s
  ==2959521== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 10 from 10)
---
 mltools/libosinfo-c.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/mltools/libosinfo-c.c b/mltools/libosinfo-c.c
index 11df1fe..00d74c1 100644
--- a/mltools/libosinfo-c.c
+++ b/mltools/libosinfo-c.c
@@ -164,17 +164,22 @@ v2v_osinfo_os_find_os_by_short_id (value dbv, value osv)
 
   os_list = osinfo_db_get_os_list (OsinfoDb_t_val (dbv));
   filter = osinfo_filter_new ();
-  osinfo_filter_add_constraint (filter, OSINFO_PRODUCT_PROP_SHORT_ID, 
String_val (osv));
+  osinfo_filter_add_constraint (filter, OSINFO_PRODUCT_PROP_SHORT_ID,
+                                String_val (osv));
   list = osinfo_list_new_filtered (OSINFO_LIST(os_list), filter);
 
   if (osinfo_list_get_length (list) == 0) {
     g_object_unref (list);
+    g_object_unref (filter);
+    g_object_unref (os_list);
     caml_raise_not_found ();
   }
 
   os = OSINFO_OS(osinfo_list_get_nth (list, 0));
   rv = Val_OsinfoOs_t (dbv, os);
   g_object_unref (list);
+  g_object_unref (filter);
+  g_object_unref (os_list);
 
   CAMLreturn (rv);
 }
-- 
2.49.0
_______________________________________________
Libguestfs mailing list -- guestfs@lists.libguestfs.org
To unsubscribe send an email to guestfs-le...@lists.libguestfs.org

Reply via email to