[PATCH weston] window: check the initial wl_display_dispatch()

Kristian Høgsberg hoegsberg at gmail.com
Thu Feb 14 09:25:56 PST 2013


On Thu, Feb 14, 2013 at 12:18:00PM +0200, Pekka Paalanen wrote:
> Check for errors in the first wl_display_dispatch() call. Otherwise
> doing something silly like
>   $ WAYLAND_SOCKET=999 ./clickdot
> will segfault.
> 
> Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
> ---
>  clients/window.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

Yup, that's better, thanks.

Kristian

> diff --git a/clients/window.c b/clients/window.c
> index f06f1d6..9752e7e 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -4362,7 +4362,12 @@ display_create(int argc, char *argv[])
>  
>  	d->registry = wl_display_get_registry(d->display);
>  	wl_registry_add_listener(d->registry, &registry_listener, d);
> -	wl_display_dispatch(d->display);
> +
> +	if (wl_display_dispatch(d->display) < 0) {
> +		fprintf(stderr, "Failed to process Wayland connection: %m\n");
> +		return NULL;
> +	}
> +
>  #ifdef HAVE_CAIRO_EGL
>  	if (init_egl(d) < 0)
>  		fprintf(stderr, "EGL does not seem to work, "
> -- 
> 1.7.12.4
> 


More information about the wayland-devel mailing list