On Tue, Nov 01, 2016 at 02:14:00PM -0500, Tom Hochstein wrote:
> 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.hochst...@nxp.com>

Reviewed-by: Bryce Harrington <br...@osg.samsung.com>

> ---
> v2: Don't call weston_wm_set_selection if there is no seat
> 
>  xwayland/selection.c      | 2 ++
>  xwayland/window-manager.c | 6 ++++--
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/xwayland/selection.c b/xwayland/selection.c
> index 641ac49..9668d17 100644
> --- a/xwayland/selection.c
> +++ b/xwayland/selection.c
> @@ -709,6 +709,8 @@ weston_wm_selection_init(struct weston_wm *wm)
>                                         wm->atom.clipboard, mask);
>  
>       seat = weston_wm_pick_seat(wm);
> +     if (seat == NULL)
> +             return;
>       wm->selection_listener.notify = weston_wm_set_selection;
>       wl_signal_add(&seat->selection_signal, &wm->selection_listener);
>  
> 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
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to