From 41bef3caaaf583ebc0faea3d574db93aeb02cae1 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Fri, 4 Jul 2025 15:33:41 +0300 Subject: [PATCH] weston-test: Fix another mem leak on shutdown path Fixes the following mem leak: ================================================================= ==191==ERROR: LeakSanitizer: detected memory leaks Direct leak of 56 byte(s) in 1 object(s) allocated from: #0 0x7f6b843f6610 in calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77 #1 0x7f6b8302f499 in output_created_listener ../tests/weston-test.c:145 #2 0x7f6b83032dcd in wet_module_init ../tests/weston-test.c:857 #3 0x7f6b842b8425 in wet_load_module ../frontend/main.c:989 #4 0x7f6b842b89eb in load_modules ../frontend/main.c:1069 #5 0x7f6b842d2711 in wet_main ../frontend/main.c:4865 #6 0x562862e934d6 in execute_compositor ../tests/weston-test-fixture-compositor.c:431 #7 0x562862e9756b in weston_test_harness_execute_as_client ../tests/weston-test-runner.c:570 #8 0x562862e81e1d in fixture_setup ../tests/drm-writeback-screenshot-test.c:48 #9 0x562862e81e9e in fixture_setup_run_ ../tests/drm-writeback-screenshot-test.c:50 #10 0x562862e97bb6 in main ../tests/weston-test-runner.c:726 #11 0x7f6b83d33ca7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Signed-off-by: Marius Vlad --- tests/weston-test.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/weston-test.c b/tests/weston-test.c index 7ac55a40b..dd83eac29 100644 --- a/tests/weston-test.c +++ b/tests/weston-test.c @@ -836,6 +836,7 @@ wet_module_init(struct weston_compositor *ec, struct weston_test *test; struct weston_output *output; struct wl_event_loop *loop; + struct weston_test_output *to, *tmp; test = zalloc(sizeof *test); if (test == NULL) @@ -881,6 +882,12 @@ out_free: if (test->log) weston_log_scope_destroy(test->log); + wl_list_for_each_safe(to, tmp, &test->output_list, link) { + wl_list_remove(&to->repaint_listener.link); + wl_list_remove(&to->link); + free(to); + } + wl_list_remove(&test->output_destroyed_listener.link); wl_list_remove(&test->destroy_listener.link); free(test);