shm: mmap returns MAP_FAILED, so use that as guard value

This commit is contained in:
Daniel Eklöf 2020-03-10 18:01:56 +01:00
parent 867dc836ab
commit cf5da1039f
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

4
shm.c
View file

@ -105,7 +105,7 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie)
*/ */
int pool_fd = -1; int pool_fd = -1;
void *mmapped = NULL; void *mmapped = MAP_FAILED;
size_t size = 0; size_t size = 0;
struct wl_shm_pool *pool = NULL; struct wl_shm_pool *pool = NULL;
@ -199,7 +199,7 @@ err:
wl_shm_pool_destroy(pool); wl_shm_pool_destroy(pool);
if (pool_fd != -1) if (pool_fd != -1)
close(pool_fd); close(pool_fd);
if (mmapped != NULL) if (mmapped != MAP_FAILED)
munmap(mmapped, size); munmap(mmapped, size);
return NULL; return NULL;