aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Olsson <martin@minimum.se>2012-07-09 11:35:57 +0200
committerKristian Høgsberg <krh@bitplanet.net>2012-07-09 17:59:45 -0400
commitc94c0946db694ec29b5aebb94a8be0501bacfbc7 (patch)
treea97b69b375ee9edbc6577617fa9d029e82f44344 /src
parentserver: Don't crash for wl_seat_set_touch(seat, NULL) (diff)
downloadwayland-c94c0946db694ec29b5aebb94a8be0501bacfbc7.tar
wayland-c94c0946db694ec29b5aebb94a8be0501bacfbc7.tar.gz
wayland-c94c0946db694ec29b5aebb94a8be0501bacfbc7.tar.bz2
wayland-c94c0946db694ec29b5aebb94a8be0501bacfbc7.tar.lz
wayland-c94c0946db694ec29b5aebb94a8be0501bacfbc7.tar.xz
wayland-c94c0946db694ec29b5aebb94a8be0501bacfbc7.tar.zst
wayland-c94c0946db694ec29b5aebb94a8be0501bacfbc7.zip
shm: Plug leak in shm_create_pool()
Diffstat (limited to 'src')
-rw-r--r--src/wayland-shm.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/wayland-shm.c b/src/wayland-shm.c
index 62afc3b..7565623 100644
--- a/src/wayland-shm.c
+++ b/src/wayland-shm.c
@@ -188,29 +188,27 @@ shm_create_pool(struct wl_client *client, struct wl_resource *resource,
pool = malloc(sizeof *pool);
if (pool == NULL) {
wl_resource_post_no_memory(resource);
- close(fd);
- return;
+ goto err_close;
}
if (size <= 0) {
wl_resource_post_error(resource,
WL_SHM_ERROR_INVALID_STRIDE,
"invalid size (%d)", size);
- close(fd);
- return;
+ goto err_free;
}
pool->refcount = 1;
pool->size = size;
pool->data = mmap(NULL, size,
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- close(fd);
if (pool->data == MAP_FAILED) {
wl_resource_post_error(resource,
WL_SHM_ERROR_INVALID_FD,
"failed mmap fd %d", fd);
- return;
+ goto err_free;
}
+ close(fd);
pool->resource.object.id = id;
pool->resource.object.interface = &wl_shm_pool_interface;
@@ -222,6 +220,11 @@ shm_create_pool(struct wl_client *client, struct wl_resource *resource,
pool->resource.destroy = destroy_pool;
wl_client_add_resource(client, &pool->resource);
+
+err_close:
+ close(fd);
+err_free:
+ free(pool);
}
static const struct wl_shm_interface shm_interface = {