Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/SDL_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,9 +719,14 @@ static void RefreshInterfaces(void) // LINUX/BSD VERSION
}

NetworkInterfaces *iface = &new_interfaces[0];
for (struct ifaddrs *i = ifaddr; i != NULL; i = i->ifa_next, iface++) {
for (struct ifaddrs *i = ifaddr; i != NULL; i = i->ifa_next) {
if (i->ifa_name == NULL) {
continue; // i guess.
continue; // not counted in the first pass, no adjustment needed.
}

if (i->ifa_addr == NULL) {
new_num_interfaces--; // was counted in the first pass, undo it.
continue;
}

// !!! FIXME: getifaddrs doesn't return the sockaddr length, so we have to go with known protocols. :/
Expand All @@ -734,7 +739,6 @@ static void RefreshInterfaces(void) // LINUX/BSD VERSION
iface->address = CreateSDLNetAddrFromSockAddr(i->ifa_addr, sizeof (struct sockaddr_in6));
} else {
new_num_interfaces--;
iface--;
continue;
}

Expand All @@ -757,6 +761,8 @@ static void RefreshInterfaces(void) // LINUX/BSD VERSION
NET_UnrefAddress(iface->broadcast); // just in case.
goto failed;
}

iface++; // only advance when a slot was actually filled.
}

succeeded:
Expand Down
Loading