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 <avrac@freebox.fr>
This commit is contained in:
Arnaud Vrac 2023-11-24 14:01:01 +01:00 committed by Marius Vlad
parent 373ee4df45
commit 238d5274a2

View File

@ -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;