1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

gnrc_sock_udp: fix null check in port generation function

Still check if the port is unused if no socket has been given.
This commit is contained in:
Sören Tempel 2020-02-05 11:56:23 +01:00
parent b37bed8a1d
commit 5cf433806e

View File

@ -74,8 +74,7 @@ static uint16_t _get_dyn_port(sock_udp_t *sock)
do {
uint16_t port = GNRC_SOCK_DYN_PORTRANGE_MIN +
(random_uint32() % GNRC_SOCK_DYN_PORTRANGE_NUM);
if ((sock == NULL) || (sock->flags & SOCK_FLAGS_REUSE_EP) ||
!_dyn_port_used(port)) {
if ((sock && (sock->flags & SOCK_FLAGS_REUSE_EP)) || !_dyn_port_used(port)) {
return port;
}
--count;