@samitouri / QOSamiQemu / commits / e96ff02669

tests: fix leaks in dbus-display-test

Close the connections and complete the method invocations. Thanks ASAN for the report. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Acked-by: Fabiano Rosas <farosas@suse.de> Message-ID: <20260122113144.2046899-2-marcandre.lureau@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Marc-André Lureau committed Jan 22, 2026 at 15:31 UTC e96ff0266900b37aa30c5ea9d662db94eae0f3fd
1 file changed +9
tests/qtest/dbus-display-test.c
+9
@@ -76,6 +76,7 @@ test_dbus_display_vm(void)
76 qemu_dbus_display1_vm_get_name(QEMU_DBUS_DISPLAY1_VM(vm)),
77 ==,
78 "dbus-test");
79 + g_clear_object(&conn);
80 qtest_quit(qts);
81 }
82
@@ -97,6 +98,8 @@ static gboolean listener_handle_scanout(
98 GVariant *arg_data,
99 TestDBusConsoleRegister *test)
100 {
101 + qemu_dbus_display1_listener_complete_scanout(object, invocation);
102 +
103 if (!test->with_map) {
104 g_main_loop_quit(test->loop);
105 }
@@ -131,6 +134,9 @@ static gboolean listener_handle_scanout_map(
134 g_assert_no_errno(addr == MAP_FAILED ? -1 : 0);
135 g_assert_no_errno(munmap(addr, len));
136
137 + qemu_dbus_display1_listener_unix_map_complete_scanout_map(object, invocation,
138 + NULL);
139 +
140 g_main_loop_quit(test->loop);
141
142 close(fd);
@@ -287,6 +293,7 @@ test_dbus_display_console(const void* data)
293
294 g_clear_object(&test.server);
295 g_clear_object(&test.listener_conn);
296 + g_clear_object(&conn);
297 qtest_quit(qts);
298 }
299
@@ -322,6 +329,7 @@ test_dbus_display_keyboard(void)
329 &err);
330 if (g_error_matches(err, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD)) {
331 g_test_skip("The VM doesn't have a console!");
332 + g_clear_object(&conn);
333 qtest_quit(qts);
334 return;
335 }
@@ -348,6 +356,7 @@ test_dbus_display_keyboard(void)
356 g_assert_cmpint(qemu_dbus_display1_keyboard_get_modifiers(
357 QEMU_DBUS_DISPLAY1_KEYBOARD(keyboard)), ==, 0);
358
359 + g_clear_object(&conn);
360 qtest_quit(qts);
361 }
362