Feature cleanup for Nifty Needlefish
[AGL/meta-agl.git] / meta-agl-core / recipes-graphics / wayland / weston / 0003-libweston-desktop-add-weston_desktop_xwayland_fini.patch
1 From e2583ca0844bd7a8ce4fc94da9ad67edf49ffd45 Mon Sep 17 00:00:00 2001
2 From: Pekka Paalanen <pekka.paalanen@collabora.com>
3 Upstream-Status: Backport
4 Date: Fri, 14 May 2021 16:12:35 +0300
5 Subject: [PATCH] libweston-desktop: add weston_desktop_xwayland_fini()
6
7 This fixes the following leaks detected by ASan in
8 ./tests/test-alpha-blending:
9
10 Direct leak of 176 byte(s) in 2 object(s) allocated from:
11     #0 0x7fb447880518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
12     #1 0x7fb4432c12d7 in zalloc ../../git/weston/include/libweston/zalloc.h:38
13     #2 0x7fb4432c2ca6 in weston_desktop_xwayland_init ../../git/weston/libweston-desktop/xwayland.c:410
14     #3 0x7fb4432baadf in weston_desktop_create ../../git/weston/libweston-desktop/libweston-desktop.c:87
15     #4 0x7fb4432e1e1f in wet_shell_init ../../git/weston/tests/weston-test-desktop-shell.c:224
16     #5 0x7fb44775fddd in wet_load_shell ../../git/weston/compositor/main.c:956
17     #6 0x7fb447770db1 in wet_main ../../git/weston/compositor/main.c:3434
18     #7 0x56172c599279 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
19     #8 0x56172c59cce5 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
20     #9 0x56172c58dc8c in fixture_setup ../../git/weston/tests/alpha-blending-test.c:65
21     #10 0x56172c58dd31 in fixture_setup_run_ ../../git/weston/tests/alpha-blending-test.c:67
22     #11 0x56172c59d29a in main ../../git/weston/tests/weston-test-runner.c:661
23     #12 0x7fb4473d509a in __libc_start_main ../csu/libc-start.c:308
24
25 Indirect leak of 144 byte(s) in 2 object(s) allocated from:
26     #0 0x7fb447880518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
27     #1 0x7fb4432bb592 in zalloc ../../git/weston/include/libweston/zalloc.h:38
28     #2 0x7fb4432bb882 in weston_desktop_client_create ../../git/weston/libweston-desktop/client.c:108
29     #3 0x7fb4432c2d0e in weston_desktop_xwayland_init ../../git/weston/libweston-desktop/xwayland.c:415
30     #4 0x7fb4432baadf in weston_desktop_create ../../git/weston/libweston-desktop/libweston-desktop.c:87
31     #5 0x7fb4432e1e1f in wet_shell_init ../../git/weston/tests/weston-test-desktop-shell.c:224
32     #6 0x7fb44775fddd in wet_load_shell ../../git/weston/compositor/main.c:956
33     #7 0x7fb447770db1 in wet_main ../../git/weston/compositor/main.c:3434
34     #8 0x56172c599279 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
35     #9 0x56172c59cce5 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
36     #10 0x56172c58dc8c in fixture_setup ../../git/weston/tests/alpha-blending-test.c:65
37     #11 0x56172c58dd31 in fixture_setup_run_ ../../git/weston/tests/alpha-blending-test.c:67
38     #12 0x56172c59d29a in main ../../git/weston/tests/weston-test-runner.c:661
39     #13 0x7fb4473d509a in __libc_start_main ../csu/libc-start.c:308
40
41 Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
42 ---
43  libweston-desktop/internal.h          |  2 ++
44  libweston-desktop/libweston-desktop.c |  2 ++
45  libweston-desktop/xwayland.c          | 16 ++++++++++++++++
46  3 files changed, 20 insertions(+)
47
48 diff --git a/libweston-desktop/internal.h b/libweston-desktop/internal.h
49 index 7a815bd87..2606d279b 100644
50 --- a/libweston-desktop/internal.h
51 +++ b/libweston-desktop/internal.h
52 @@ -240,5 +240,7 @@ weston_desktop_wl_shell_create(struct weston_desktop *desktop,
53  
54  void
55  weston_desktop_xwayland_init(struct weston_desktop *desktop);
56 +void
57 +weston_desktop_xwayland_fini(struct weston_desktop *desktop);
58  
59  #endif /* WESTON_DESKTOP_INTERNAL_H */
60 diff --git a/libweston-desktop/libweston-desktop.c b/libweston-desktop/libweston-desktop.c
61 index c1efd2012..2b42ac7e3 100644
62 --- a/libweston-desktop/libweston-desktop.c
63 +++ b/libweston-desktop/libweston-desktop.c
64 @@ -95,6 +95,8 @@ weston_desktop_destroy(struct weston_desktop *desktop)
65         if (desktop == NULL)
66                 return;
67  
68 +       weston_desktop_xwayland_fini(desktop);
69 +
70         if (desktop->wl_shell != NULL)
71                 wl_global_destroy(desktop->wl_shell);
72         if (desktop->xdg_shell_v6 != NULL)
73 diff --git a/libweston-desktop/xwayland.c b/libweston-desktop/xwayland.c
74 index 711c8a30c..c1c5fc4a7 100644
75 --- a/libweston-desktop/xwayland.c
76 +++ b/libweston-desktop/xwayland.c
77 @@ -423,3 +423,19 @@ weston_desktop_xwayland_init(struct weston_desktop *desktop)
78         compositor->xwayland = xwayland;
79         compositor->xwayland_interface = &weston_desktop_xwayland_interface;
80  }
81 +
82 +void
83 +weston_desktop_xwayland_fini(struct weston_desktop *desktop)
84 +{
85 +       struct weston_compositor *compositor = weston_desktop_get_compositor(desktop);
86 +       struct weston_desktop_xwayland *xwayland;
87 +
88 +       xwayland = compositor->xwayland;
89 +
90 +       weston_desktop_client_destroy(xwayland->client);
91 +       weston_layer_fini(&xwayland->layer);
92 +       free(xwayland);
93 +
94 +       compositor->xwayland = NULL;
95 +       compositor->xwayland_interface = NULL;
96 +}
97 -- 
98 GitLab
99