From: Guus Sliepen Date: Fri, 10 Jul 2020 20:15:39 +0000 (+0200) Subject: Fix a crash with some network configurations. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=c8af33c1b1b25dc5e9b42892e09dbb65fd5bd766;p=meshlink Fix a crash with some network configurations. It is apparently possible for getifaddrs() to return a struct ifaddrs that contains a NULL ifa_addr pointer. --- diff --git a/src/meshlink.c b/src/meshlink.c index 0fe7343c..d54fe30b 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -366,7 +366,7 @@ char *meshlink_get_local_address_for_family(meshlink_handle_t *mesh, int family) for(struct ifaddrs *ifap = ifa; ifap; ifap = ifap->ifa_next) { sockaddr_t *sa = (sockaddr_t *)ifap->ifa_addr; - if(sa->sa.sa_family != family) { + if(!sa || sa->sa.sa_family != family) { continue; }