[PATCH weston] xwayland: Fix crash when run with no input device
Tom Hochstein
tom.hochstein at nxp.com
Tue Nov 1 01:38:29 UTC 2016
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 at nxp.com>
---
xwayland/selection.c | 10 +++++++---
xwayland/window-manager.c | 6 ++++--
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/xwayland/selection.c b/xwayland/selection.c
index 641ac49..60f9f20 100644
--- a/xwayland/selection.c
+++ b/xwayland/selection.c
@@ -655,8 +655,10 @@ weston_wm_set_selection(struct wl_listener *listener, void *data)
struct weston_seat *seat = data;
struct weston_wm *wm =
container_of(listener, struct weston_wm, selection_listener);
- struct weston_data_source *source = seat->selection_data_source;
+ struct weston_data_source *source = NULL;
+ if (seat != NULL)
+ source = seat->selection_data_source;
if (source == NULL) {
if (wm->selection_owner == wm->selection_window)
xcb_set_selection_owner(wm->conn,
@@ -709,8 +711,10 @@ weston_wm_selection_init(struct weston_wm *wm)
wm->atom.clipboard, mask);
seat = weston_wm_pick_seat(wm);
- wm->selection_listener.notify = weston_wm_set_selection;
- wl_signal_add(&seat->selection_signal, &wm->selection_listener);
+ if (seat != NULL) {
+ wm->selection_listener.notify = weston_wm_set_selection;
+ wl_signal_add(&seat->selection_signal, &wm->selection_listener);
+ }
weston_wm_set_selection(&wm->selection_listener, seat);
}
diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index 0e26d7c..15e2ca2 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -1306,8 +1306,10 @@ weston_wm_handle_reparent_notify(struct weston_wm *wm, xcb_generic_event_t *even
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 *
--
1.9.1
More information about the wayland-devel
mailing list