From: Simon Marchi Date: Wed, 8 Mar 2023 21:54:25 +0000 (-0500) Subject: Fix: tests: free message iterator class in test_graph_topo.c X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=44b263a86c5d6ead7e68191c330ee835bd19ea7d Fix: tests: free message iterator class in test_graph_topo.c In a build with --enable-asan and optimizations (-O2), I see: Direct leak of 112 byte(s) in 1 object(s) allocated from: #0 0x7fc88d6bf411 in __interceptor_calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77 #1 0x7fc88d3b4631 in g_malloc0 (/usr/lib/libglib-2.0.so.0+0x53631) #2 0x563fdbbb98c7 in init_test /home/smarchi/src/babeltrace/tests/lib/test_graph_topo.c:330 #3 0x563fdbbb98c7 in main /home/smarchi/src/babeltrace/tests/lib/test_graph_topo.c:711 #4 0x7fc88d19d78f (/usr/lib/libc.so.6+0x2378f) For some reason, that leak does not show up on a -O0 build. Anyhow, call BT_MESSAGE_ITERATOR_CLASS_PUT_REF_AND_RESET, it's the right thing to do to clean things up. Change-Id: I875d8961c2eb4915fbc13706b9148151e82e26d8 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/9626 Tested-by: jenkins Reviewed-by: Jérémie Galarneau --- diff --git a/tests/lib/test_graph_topo.c b/tests/lib/test_graph_topo.c index cd3284be..c31f7c8b 100644 --- a/tests/lib/test_graph_topo.c +++ b/tests/lib/test_graph_topo.c @@ -358,6 +358,7 @@ void fini_test(void) bt_component_class_source_put_ref(src_comp_class); bt_component_class_sink_put_ref(sink_comp_class); g_array_free(events, TRUE); + BT_MESSAGE_ITERATOR_CLASS_PUT_REF_AND_RESET(msg_iter_class); } static