From 5b6a2b0eaff1ffef84d728a6c76c044c7f01a1d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 18 Jul 2021 16:44:49 +0200 Subject: [PATCH] =?UTF-8?q?shm:=20get=5Fmany():=20allow=20=E2=80=9CNULL?= =?UTF-8?q?=E2=80=9D=20buffers=20-=20buffers=20where=20width=20or=20height?= =?UTF-8?q?=20is=200?= 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));