From 238d5274a20b4afc968af8b57bfb1076fed004be Mon Sep 17 00:00:00 2001 From: Arnaud Vrac Date: Fri, 24 Nov 2023 14:01:01 +0100 Subject: [PATCH] fullscreen-shell: do not crash when presenting a null surface The protocol allows presenting a null surface, in this case we would crash. This can be reproduced with weston-fullscreen and pressing 'o'. Signed-off-by: Arnaud Vrac --- fullscreen-shell/fullscreen-shell.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fullscreen-shell/fullscreen-shell.c b/fullscreen-shell/fullscreen-shell.c index 1ca9cf399..733e1a3e3 100644 --- a/fullscreen-shell/fullscreen-shell.c +++ b/fullscreen-shell/fullscreen-shell.c @@ -131,6 +131,12 @@ replace_default_surface(struct fullscreen_shell *shell, struct weston_surface *s prev = container_of(shell->default_surface_list.prev, struct fs_client_surface, link); + if (prev) + remove_default_surface(prev); + + if (!surface) + return; + surf = zalloc(sizeof *surf); if (!surf) return; @@ -138,9 +144,6 @@ replace_default_surface(struct fullscreen_shell *shell, struct weston_surface *s surf->surface = surface; surf->method = method; - if (prev) - remove_default_surface(prev); - wl_list_insert(shell->default_surface_list.prev, &surf->link); surf->surface_destroyed.notify = default_surface_destroy_listener;