]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
net/socket: fix coverity issue
authorJens Freimann <jfreimann@redhat.com>
Mon, 6 Nov 2017 14:05:46 +0000 (15:05 +0100)
committerJason Wang <jasowang@redhat.com>
Mon, 13 Nov 2017 10:05:12 +0000 (18:05 +0800)
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>
net/socket.c

index 83a2a31025b61aa0300366404b92beecb744535f..6917fbcbf582cf3606abe168a55918f262250bcc 100644 (file)
@@ -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)",