shm: get_many(): allow “NULL” buffers - buffers where width or height is 0

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.
This commit is contained in:
Daniel Eklöf 2021-07-18 16:44:49 +02:00
parent e8e9cd5595
commit 5b6a2b0eaf
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

4
shm.c
View file

@ -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));