summary refs log tree commit diff stats
path: root/net/socket.c
diff options
context:
space:
mode:
authorJens Freimann <jfreimann@redhat.com>2017-11-06 15:05:46 +0100
committerJason Wang <jasowang@redhat.com>2017-11-13 18:05:12 +0800
commitbb160b571fe469b03228d4502c75a18045978a74 (patch)
treef42459bb94cd7f55a75a7cfce3d2e8ee2393000a /net/socket.c
parent5e89dc01133f8f5e621f6b66b356c6f37d31dafb (diff)
downloadfocaccia-qemu-bb160b571fe469b03228d4502c75a18045978a74.tar.gz
focaccia-qemu-bb160b571fe469b03228d4502c75a18045978a74.zip
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 <peter.maydell@linaro.org>
Signed-off-by: Jens Freimann <jfreimann@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'net/socket.c')
-rw-r--r--net/socket.c2
1 files changed, 1 insertions, 1 deletions
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)",