net: get_local_addresses - ifaddrs.ifa_addr can be NULL

The pointer ifa_addr in struct ifaddrs can be NULL and indeed it occurs
(perhaps with interfaces without assigned addrs?). Steps to reproduce:
```
uv -x sdp -t testcard -c lavc:subs=420
````
This commit is contained in:
Martin Pulec
2024-06-05 08:21:13 +02:00
parent 3aec782d03
commit 2c22850a20

View File

@@ -315,6 +315,10 @@ bool get_local_addresses(struct sockaddr_storage *addrs, size_t *len, int ip_ver
getifaddrs(&a);
struct ifaddrs* p = a;
while (NULL != p) {
if (p->ifa_addr == NULL) {
p = p->ifa_next;
continue;
}
if ((ip_version == 0 && (p->ifa_addr->sa_family == AF_INET || p->ifa_addr->sa_family == AF_INET6)) ||
(ip_version == 4 && p->ifa_addr->sa_family == AF_INET) ||
(ip_version == 6 && p->ifa_addr->sa_family == AF_INET6)) {