[PATCH] Add error handling for wl_cursors

Bryce W. Harrington b.harrington at samsung.com
Tue Mar 18 11:57:09 PDT 2014


LGTM

Reviewed-by: Bryce Harrington <b.harrington at samsung.com>

On Tue, Mar 18, 2014 at 11:29:00AM +0100, Hardening wrote:
> This patch adds some error management in wayland cursors
> ---
>  cursor/wayland-cursor.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/cursor/wayland-cursor.c b/cursor/wayland-cursor.c
> index b16f530..dba3b51 100644
> --- a/cursor/wayland-cursor.c
> +++ b/cursor/wayland-cursor.c
> @@ -94,6 +94,8 @@ shm_pool_resize(struct shm_pool *pool, int size)
>  
>  	pool->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
>  			  pool->fd, 0);
> +	if (pool->data == (void *)-1)
> +		return 0;
>  	pool->size = size;
>  
>  	return 1;
> @@ -391,17 +393,15 @@ wl_cursor_theme_load(const char *name, int size, struct wl_shm *shm)
>  		name = "default";
>  
>  	theme->name = strdup(name);
> +	if (!theme->name)
> +		goto out_error_name;
>  	theme->size = size;
>  	theme->cursor_count = 0;
>  	theme->cursors = NULL;
>  
> -	theme->pool =
> -		shm_pool_create(shm, size * size * 4);
> -	if (!theme->pool) {
> -		free(theme->name);
> -		free(theme);
> -		return NULL;
> -	}
> +	theme->pool = shm_pool_create(shm, size * size * 4);
> +	if (!theme->pool)
> +		goto out_error_pool;
>  
>  	xcursor_load_theme(name, size, load_callback, theme);
>  
> @@ -409,6 +409,12 @@ wl_cursor_theme_load(const char *name, int size, struct wl_shm *shm)
>  		load_default_theme(theme);
>  
>  	return theme;
> +
> +out_error_pool:
> +	free(theme->name);
> +out_error_name:
> +	free(theme);
> +	return NULL;
>  }
>  
>  /** Destroys a cursor theme object
> -- 
> 1.8.1.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