From 012bf26764ac0eecc7f57774c4ece290cfa9d8a4 Mon Sep 17 00:00:00 2001 From: riccardom Date: Sun, 18 Apr 2010 15:59:27 +0000 Subject: [PATCH] Avoid segfault without available interfaces On gnu/linux pcap_findalldevs can return 0 but provide a NULL interfaces list. This could be common on !windows because from what i can see normal users can't list devices :|. --- desmume/src/wifi.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/desmume/src/wifi.cpp b/desmume/src/wifi.cpp index 6c752517b..41a01a90d 100644 --- a/desmume/src/wifi.cpp +++ b/desmume/src/wifi.cpp @@ -1930,8 +1930,10 @@ bool SoftAP_Init() char errbuf[PCAP_ERRBUF_SIZE]; pcap_if_t *alldevs; + int ret; - if(driver->PCAP_findalldevs(&alldevs, errbuf) == -1) + ret = driver->PCAP_findalldevs(&alldevs, errbuf); + if (ret == -1 || alldevs == NULL) { WIFI_LOG(1, "SoftAP: PCap: failed to find any network adapter: %s\n", errbuf); return false;