From e9f1638750db342fbf26fc9477a970ab2e3e439d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 25 Mar 2020 18:32:41 +0100 Subject: [PATCH] shm: handle ftruncate failure --- shm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shm.c b/shm.c index dc633ae3..7ac1f6c8 100644 --- a/shm.c +++ b/shm.c @@ -264,8 +264,12 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie, if (scrollable && !can_punch_hole) { initial_offset = 0; memfd_size = size; - ftruncate(pool_fd, memfd_size); scrollable = false; + + if (ftruncate(pool_fd, memfd_size) < 0) { + LOG_ERRNO("failed to set size of SHM backing memory file"); + goto err; + } } real_mmapped = mmap(