On Tue, Nov 10, 2026 at 02:39:33PM +0200, Manos Pitsidianakis wrote: > g_new0() might return NULL, which is UB if passed to a memcpy > implementation that does not expect it (not in the usual case). > > Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3778 > Signed-off-by: Manos Pitsidianakis <[email protected]> > --- > hw/audio/virtio-snd.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c > index 89406f0a3a..a7d749f24f 100644 > --- a/hw/audio/virtio-snd.c > +++ b/hw/audio/virtio-snd.c > @@ -267,6 +267,11 @@ static void virtio_snd_handle_pcm_info(VirtIOSound *s, > return; > } > > + if (count == 0) { > + cmd->payload_size = 0; > + cmd->resp.code = cpu_to_le32(VIRTIO_SND_S_OK); > + return; > + } > pcm_info = g_new0(virtio_snd_pcm_info, count); > for (uint32_t i = 0; i < count; i++) { > stream_id = i + start_id; > > -- > 2.56.0 > >
Reviewed-by: Jim MacArthur <[email protected]>
