summaryrefslogtreecommitdiff
path: root/cursor
diff options
context:
space:
mode:
authorMartin Olsson <martin@minimum.se>2012-07-09 11:35:54 +0200
committerKristian Høgsberg <krh@bitplanet.net>2012-07-09 17:59:08 -0400
commit00902b38151d6b4373584eb52dc44143825ef88f (patch)
treecc51ffe1b487fefebc64f61b84b90449a93d6e2c /cursor
parent8a023688c07fe2d377c4bc9631ce2fe7a9afee60 (diff)
wayland-cursor: Add error handling for shm_pool_create()
Diffstat (limited to 'cursor')
-rw-r--r--cursor/wayland-cursor.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/cursor/wayland-cursor.c b/cursor/wayland-cursor.c
index 7621020..36a8b54 100644
--- a/cursor/wayland-cursor.c
+++ b/cursor/wayland-cursor.c
@@ -49,27 +49,29 @@ shm_pool_create(struct wl_shm *shm, int size)
pool->fd = mkstemp(filename);
if (pool->fd < 0)
- return NULL;
+ goto err_free;
- if (ftruncate(pool->fd, size) < 0) {
- close(pool->fd);
- return NULL;
- }
+ if (ftruncate(pool->fd, size) < 0)
+ goto err_close;
pool->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
pool->fd, 0);
unlink(filename);
- if (pool->data == MAP_FAILED) {
- close(pool->fd);
- return NULL;
- }
+ if (pool->data == MAP_FAILED)
+ goto err_close;
pool->pool = wl_shm_create_pool(shm, pool->fd, size);
pool->size = size;
pool->used = 0;
return pool;
+
+err_close:
+ close(pool->fd);
+err_free:
+ free(pool);
+ return NULL;
}
static int