mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
Add error handling for wl_cursors
This patch adds some error management in wayland cursors Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
This commit is contained in:
parent
051f3838de
commit
256324773f
1 changed files with 13 additions and 7 deletions
|
|
@ -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->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||||
pool->fd, 0);
|
pool->fd, 0);
|
||||||
|
if (pool->data == (void *)-1)
|
||||||
|
return 0;
|
||||||
pool->size = size;
|
pool->size = size;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -391,17 +393,15 @@ wl_cursor_theme_load(const char *name, int size, struct wl_shm *shm)
|
||||||
name = "default";
|
name = "default";
|
||||||
|
|
||||||
theme->name = strdup(name);
|
theme->name = strdup(name);
|
||||||
|
if (!theme->name)
|
||||||
|
goto out_error_name;
|
||||||
theme->size = size;
|
theme->size = size;
|
||||||
theme->cursor_count = 0;
|
theme->cursor_count = 0;
|
||||||
theme->cursors = NULL;
|
theme->cursors = NULL;
|
||||||
|
|
||||||
theme->pool =
|
theme->pool = shm_pool_create(shm, size * size * 4);
|
||||||
shm_pool_create(shm, size * size * 4);
|
if (!theme->pool)
|
||||||
if (!theme->pool) {
|
goto out_error_pool;
|
||||||
free(theme->name);
|
|
||||||
free(theme);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
xcursor_load_theme(name, size, load_callback, theme);
|
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);
|
load_default_theme(theme);
|
||||||
|
|
||||||
return theme;
|
return theme;
|
||||||
|
|
||||||
|
out_error_pool:
|
||||||
|
free(theme->name);
|
||||||
|
out_error_name:
|
||||||
|
free(theme);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Destroys a cursor theme object
|
/** Destroys a cursor theme object
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue