From 819054ceac9e4143dc0c1992d37f0f6097a7605d Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Fri, 11 Jun 2021 16:54:12 +0300 Subject: [PATCH] tests: fix leaks in bad-buffer Fixes all ASan reported leaks for this test. If frame_callback_wait_nofail() returns before the callback is handled, the callback is not destroyed automatically. This happens on a protocol error. This test intentionally triggers a protocol error. Signed-off-by: Pekka Paalanen --- tests/bad-buffer-test.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/bad-buffer-test.c b/tests/bad-buffer-test.c index 360a81ce..31f72cb8 100644 --- a/tests/bad-buffer-test.c +++ b/tests/bad-buffer-test.c @@ -170,6 +170,7 @@ TEST(test_truncated_shm_file) struct client *client; struct wl_buffer *bad_buffer; struct wl_surface *surface; + struct wl_callback *frame_cb; int frame; client = create_client_and_test_surface(46, 76, 111, 134); @@ -180,10 +181,14 @@ TEST(test_truncated_shm_file) wl_surface_attach(surface, bad_buffer, 0, 0); wl_surface_damage(surface, 0, 0, 200, 200); - frame_callback_set(surface, &frame); + frame_cb = frame_callback_set(surface, &frame); wl_surface_commit(surface); - frame_callback_wait_nofail(client, &frame); + if (!frame_callback_wait_nofail(client, &frame)) + wl_callback_destroy(frame_cb); expect_protocol_error(client, &wl_buffer_interface, WL_SHM_ERROR_INVALID_FD); + + wl_buffer_destroy(bad_buffer); + client_destroy(client); }