xwayland: Fix crash when run with no input device
Starting an xterm with no input device led to a crash
because weston_wm_pick_seat() was returning garbage and
weston_wm_selection_init() was trying to use the garbage.
Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index b6a3aa2..c0eb7b0 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -1306,8 +1306,10 @@
struct weston_seat *
weston_wm_pick_seat(struct weston_wm *wm)
{
- return container_of(wm->server->compositor->seat_list.next,
- struct weston_seat, link);
+ struct wl_list *seats = wm->server->compositor->seat_list.next;
+ if (wl_list_empty(seats))
+ return NULL;
+ return container_of(seats, struct weston_seat, link);
}
static struct weston_seat *