[PATCH 2/3] shm: Do not attempt mmap if no file descriptor was received

Kristian Høgsberg hoegsberg at gmail.com
Fri Nov 15 16:21:24 PST 2013


On Fri, Nov 15, 2013 at 02:17:55PM +0100, Lubomir Rintel wrote:
> This is just for the sake of  cleanliness and correct error handling.
> Without this the mmap would fail emitting an error message about failed
> mapping to the client and a close of bogus file descriptor would be
> attempted, which is harmless since it can not fail.

Cf the comments, on patch 1/3, we'll never get a -1 fd.

Kristian

> Signed-off-by: Lubomir Rintel <lkundrak at v3.sk>
> ---
>  src/wayland-shm.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/wayland-shm.c b/src/wayland-shm.c
> index 28f52f4..ad92dba 100644
> --- a/src/wayland-shm.c
> +++ b/src/wayland-shm.c
> @@ -220,6 +220,13 @@ shm_create_pool(struct wl_client *client, struct wl_resource *resource,
>  {
>  	struct wl_shm_pool *pool;
>  
> +	if (fd < 0) {
> +		wl_resource_post_error(resource,
> +				       WL_SHM_ERROR_INVALID_FD,
> +				       "file descriptor expected");
> +		return;
> +	}
> +
>  	pool = malloc(sizeof *pool);
>  	if (pool == NULL) {
>  		wl_client_post_no_memory(client);
> -- 
> 1.8.4.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