From 5b6a2b0eaff1ffef84d728a6c76c044c7f01a1d8 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 18 Jul 2021 16:44:49 +0200 Subject: shm: get_many(): allow “NULL” buffers - buffers where width or height is 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a zero-sized buffer is requested, simply return a NULL buffer, instead of crashing with a Wayland protocol error. This makes it easier to request many buffers, where some may be zero-sized, without having to pack the width/height and bufs arrays. --- shm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shm.c b/shm.c index 0e55011d..60e45d4d 100644 --- a/shm.c +++ b/shm.c @@ -436,6 +436,10 @@ get_new_buffers(struct buffer_chain *chain, size_t count, }; for (size_t i = 0; i < count; i++) { + if (sizes[i] == 0) { + bufs[i] = NULL; + continue; + } /* Push to list of available buffers, but marked as 'busy' */ struct buffer_private *buf = xmalloc(sizeof(*buf)); -- cgit v1.3