[krh/wayland/next 4/5] wayland-server: Make sure client object exist before dereferencing.

Kristian Høgsberg hoegsberg at gmail.com
Tue Oct 16 08:22:55 PDT 2012


On Fri, Oct 12, 2012 at 11:28:27AM +0200, John Kåre Alsaker wrote:
> ---
>  src/wayland-server.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index f076dcb..22e6a4e 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -992,7 +992,9 @@ bind_display(struct wl_client *client,
>  	client->display_resource =
>  		wl_client_add_object(client, &wl_display_interface,
>  				     &display_interface, id, display);
> -	client->display_resource->destroy = destroy_client_display_resource;
> +
> +	if(client->display_resource)

(space between 'if' and '(')

> +		client->display_resource->destroy = destroy_client_display_resource;

Normally we would do

	wl_resource_post_no_memory(resource);

here, but since this is about creating the initial display resource we
don't have anywere to send that error.  So what you're doing is fine,
but we need to verify that client->display_resource is non-NULL after
calling bind_display() in wl_client_create() and clean up if it's
NULL.  Then in socket_data, we need to close the fd if
wl_client_create() returns NULL.

Kristian

>  }
>  
>  WL_EXPORT struct wl_display *
> -- 
> 1.7.12.2
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list