aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-03-10 17:01:56 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-03-10 17:06:10 +0000
commitcf5da1039ffb53a9ae1d789a78835b9573a95d4b (patch)
tree8279dc7ac72909b16d921a739966d2d9220ac3a5
parentshm: set pool_fd=1 after closing it, to avoid double-closing on error (diff)
shm: mmap returns MAP_FAILED, so use that as guard value
-rw-r--r--shm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/shm.c b/shm.c
index 95b7ac78..54015798 100644
--- a/shm.c
+++ b/shm.c
@@ -105,7 +105,7 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie)
*/
int pool_fd = -1;
- void *mmapped = NULL;
+ void *mmapped = MAP_FAILED;
size_t size = 0;
struct wl_shm_pool *pool = NULL;
@@ -199,7 +199,7 @@ err:
wl_shm_pool_destroy(pool);
if (pool_fd != -1)
close(pool_fd);
- if (mmapped != NULL)
+ if (mmapped != MAP_FAILED)
munmap(mmapped, size);
return NULL;