Don't remember this -- seems a little extra error checking is done.

This commit is contained in:
Mike Brady
2014-04-30 20:39:09 +01:00
parent 6941ac515d
commit c1cedcfaf5
+4 -2
View File
@@ -62,14 +62,16 @@ static int mdns_tinysvcmdns_register(char *apname, int port) {
// Look for an ipv4/ipv6 non-loopback interface to use as the main one.
for (ifa = ifalist; ifa != NULL; ifa = ifa->ifa_next)
{
if (!(ifa->ifa_flags & IFF_LOOPBACK) && ifa->ifa_addr->sa_family == AF_INET)
if (!(ifa->ifa_flags & IFF_LOOPBACK) && ifa->ifa_addr &&
ifa->ifa_addr->sa_family == AF_INET)
{
uint32_t main_ip = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr;
mdnsd_set_hostname(svr, hostname, main_ip);
break;
}
else if (!(ifa->ifa_flags & IFF_LOOPBACK) && ifa->ifa_addr->sa_family == AF_INET6)
else if (!(ifa->ifa_flags & IFF_LOOPBACK) && ifa->ifa_addr &&
ifa->ifa_addr->sa_family == AF_INET6)
{
struct in6_addr *addr = &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr;