diff --git a/src/switch_utils.c b/src/switch_utils.c index 555c3e341a..61f712b7c9 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -258,12 +258,13 @@ SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int fam getaddrinfo(base, NULL, NULL, &address_info); - if (WSAIoctl(tmp_socket, + if (!address_info || WSAIoctl(tmp_socket, SIO_ROUTING_INTERFACE_QUERY, address_info->ai_addr, (DWORD) address_info->ai_addrlen, &l_address, sizeof(l_address), (LPDWORD) & l_address_len, NULL, NULL)) { closesocket(tmp_socket); - freeaddrinfo(address_info); + if (address_info) + freeaddrinfo(address_info); return status; }