diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c index 51c5bc86ee..0484b6abec 100644 --- a/net/udp/udp_conn.c +++ b/net/udp/udp_conn.c @@ -124,7 +124,7 @@ static FAR struct udp_conn_s *udp_find_conn(uint8_t domain, if (domain == PF_INET) #endif { - if (conn->lport == portno && + if (conn->domain == PF_INET && conn->lport == portno && (net_ipv4addr_cmp(conn->u.ipv4.laddr, ipaddr->ipv4.laddr) || net_ipv4addr_cmp(conn->u.ipv4.laddr, INADDR_ANY))) { @@ -138,7 +138,7 @@ static FAR struct udp_conn_s *udp_find_conn(uint8_t domain, else #endif { - if (conn->lport == portno && + if (conn->domain == PF_INET6 && conn->lport == portno && (net_ipv6addr_cmp(conn->u.ipv6.laddr, ipaddr->ipv6.laddr) || net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_unspecaddr))) {