From fe340830231294e289ca19867ea1f3bbf5ca1293 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Fri, 25 Nov 2011 16:07:52 +0200 Subject: [PATCH] shell: fix resume_desktop for zero clients Fix two bugs: - if there are no backgrounds at all, the background pointer would have been bogus. Lead to a segfault. - if the hidden_surface_list is empty, wl_list_insert_list() would corrupt the list. Lead to a hang in pick_surface(). Signed-off-by: Pekka Paalanen --- compositor/shell.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/compositor/shell.c b/compositor/shell.c index 7cb7c4e6..509d4488 100644 --- a/compositor/shell.c +++ b/compositor/shell.c @@ -518,16 +518,23 @@ static void resume_desktop(struct wl_shell *shell) { struct wlsc_surface *surface; - struct shell_surface *background; + struct wl_list *list; wl_list_for_each(surface, &shell->hidden_surface_list, link) wlsc_surface_configure(surface, surface->x, surface->y, surface->width, surface->height); - background = container_of(shell->backgrounds.prev, - struct shell_surface, link); - wl_list_insert_list(background->surface->link.prev, - &shell->hidden_surface_list); + if (wl_list_empty(&shell->backgrounds)) { + list = &shell->compositor->surface_list; + } else { + struct shell_surface *background; + background = container_of(shell->backgrounds.prev, + struct shell_surface, link); + list = background->surface->link.prev; + } + + if (!wl_list_empty(&shell->hidden_surface_list)) + wl_list_insert_list(list, &shell->hidden_surface_list); wl_list_init(&shell->hidden_surface_list); shell->locked = false;