[vlc-commits] xdg-shell: fix leak on error
Rémi Denis-Courmont
git at videolan.org
Thu May 24 08:00:18 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed May 23 23:38:11 2018 +0300| [b4e6615b88b7160d8b4ccb00dd5690062a4011d9] | committer: Rémi Denis-Courmont
xdg-shell: fix leak on error
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b4e6615b88b7160d8b4ccb00dd5690062a4011d9
---
modules/video_output/wayland/xdg-shell.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/modules/video_output/wayland/xdg-shell.c b/modules/video_output/wayland/xdg-shell.c
index 1e1b8fca9d..d516d8977b 100644
--- a/modules/video_output/wayland/xdg-shell.c
+++ b/modules/video_output/wayland/xdg-shell.c
@@ -483,6 +483,7 @@ static int Open(vout_window_t *wnd, const vout_window_cfg_t *cfg)
sys->fullscreen = false;
wl_list_init(&sys->seats);
wnd->sys = sys;
+ wnd->handle.wl = NULL;
/* Connect to the display server */
char *dpy_name = var_InheritString(wnd, "wl-display");
@@ -511,13 +512,13 @@ static int Open(vout_window_t *wnd, const vout_window_cfg_t *cfg)
if (sys->compositor == NULL || sys->wm_base == NULL)
goto error;
- xdg_wm_base_add_listener(sys->wm_base, &xdg_wm_base_cbs, NULL);
-
/* Create a surface */
struct wl_surface *surface = wl_compositor_create_surface(sys->compositor);
if (surface == NULL)
goto error;
+ xdg_wm_base_add_listener(sys->wm_base, &xdg_wm_base_cbs, NULL);
+
struct xdg_surface *xdg_surface =
xdg_wm_base_get_xdg_surface(sys->wm_base, surface);
if (xdg_surface == NULL)
@@ -603,6 +604,8 @@ error:
xdg_surface_destroy(sys->surface);
if (sys->wm_base != NULL)
xdg_wm_base_destroy(sys->wm_base);
+ if (wnd->handle.wl != NULL)
+ wl_surface_destroy(wnd->handle.wl);
if (sys->compositor != NULL)
wl_compositor_destroy(sys->compositor);
if (sys->registry != NULL)
@@ -629,8 +632,8 @@ static void Close(vout_window_t *wnd)
org_kde_kwin_server_decoration_manager_destroy(sys->deco_manager);
xdg_toplevel_destroy(sys->toplevel);
xdg_surface_destroy(sys->surface);
- wl_surface_destroy(wnd->handle.wl);
xdg_wm_base_destroy(sys->wm_base);
+ wl_surface_destroy(wnd->handle.wl);
wl_compositor_destroy(sys->compositor);
wl_registry_destroy(sys->registry);
wl_display_disconnect(wnd->display.wl);
More information about the vlc-commits
mailing list