From 7be8e0ebc0788f79552edc4261aae89a679cbeb1 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sun, 24 May 2026 19:03:28 -0400
Subject: [PATCH] interfaces: Haiku's getifaddrs() returns interfaces with NULL
ifa_addr fields.
So check for this explicitly, so as not to crash. :)
Reference Issue #166.
---
src/SDL_net.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/SDL_net.c b/src/SDL_net.c
index 01b5a3f..ac0d2ab 100644
--- a/src/SDL_net.c
+++ b/src/SDL_net.c
@@ -713,7 +713,7 @@ static void RefreshInterfaces(void) // LINUX/BSD VERSION
NetworkInterface *new_interfaces = NULL;
int new_num_interfaces = 0;
for (struct ifaddrs *i = ifaddr; i != NULL; i = i->ifa_next) {
- if (i->ifa_name != NULL) {
+ if (i->ifa_name && i->ifa_addr) {
new_num_interfaces++;
}
}
@@ -729,7 +729,7 @@ static void RefreshInterfaces(void) // LINUX/BSD VERSION
NetworkInterface *iface = &new_interfaces[0];
for (struct ifaddrs *i = ifaddr; i != NULL; i = i->ifa_next, iface++) {
- if (i->ifa_name == NULL) {
+ if (!i->ifa_name || !i->ifa_addr) {
continue; // i guess.
}