From: Jens Freimann Date: Mon, 6 Nov 2017 14:05:46 +0000 (+0100) Subject: net/socket: fix coverity issue X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=bb160b571fe469b03228d4502c75a18045978a74;p=qemu.git net/socket: fix coverity issue This fixes coverity issue CID1005339. Make sure that saddr is not used uninitialized if the mcast parameter is NULL. Cc: qemu-stable@nongnu.org Reported-by: Peter Maydell Signed-off-by: Jens Freimann Signed-off-by: Jason Wang --- diff --git a/net/socket.c b/net/socket.c index 83a2a31025..6917fbcbf5 100644 --- a/net/socket.c +++ b/net/socket.c @@ -373,7 +373,7 @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer, net_socket_read_poll(s, true); /* mcast: save bound address as dst */ - if (is_connected) { + if (is_connected && mcast != NULL) { s->dgram_dst = saddr; snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=%d (cloned mcast=%s:%d)",