Fix: tests: free message iterator class in test_graph_topo.c
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 8 Mar 2023 21:54:25 +0000 (16:54 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 10 Mar 2023 16:39:55 +0000 (11:39 -0500)
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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9626
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/lib/test_graph_topo.c

index cd3284be152d1dbdfded071aa68004fbc70156c6..c31f7c8be4a309deee02787099caa580512cb1eb 100644 (file)
@@ -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
This page took 0.026636 seconds and 4 git commands to generate.