From c8af33c1b1b25dc5e9b42892e09dbb65fd5bd766 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Fri, 10 Jul 2020 22:15:39 +0200 Subject: [PATCH] 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. --- src/meshlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } -- 2.39.5