]> git.proxmox.com Git - mirror_qemu.git/commit
nbd/server: Silence clang sanitizer warning
authorEric Blake <eblake@redhat.com>
Mon, 15 Nov 2021 22:39:43 +0000 (16:39 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 16 Nov 2021 14:45:33 +0000 (08:45 -0600)
commit76df2b8d695b07d85cce7db753a51cdbfe42b445
treeda39022ad64309a3148f6a2931085ea78366f04c
parent9f0f846465d4c52ce9857787e947dffb64367fae
nbd/server: Silence clang sanitizer warning

clang's sanitizer is picky: memset(NULL, x, 0) is technically
undefined behavior, even though no sane implementation of memset()
deferences the NULL.  Caught by the nbd-qemu-allocation iotest.

The alternative to checking before each memset is to instead force an
allocation of 1 element instead of g_new0(type, 0)'s behavior of
returning NULL for a 0-length array.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Fixes: 3b1f244c59 (nbd: Allow export of multiple bitmaps for one device)
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20211115223943.626416-1-eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
nbd/server.c