From a1fbdd04a6ba09780b4f4322041747bde33b25a6 Mon Sep 17 00:00:00 2001 From: mtabachenko Date: Sun, 20 Jan 2013 16:32:23 +0000 Subject: [PATCH] - fix crash when use wrong index bridge adapter; --- desmume/src/wifi.cpp | 9 ++++++++- desmume/src/windows/main.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/desmume/src/wifi.cpp b/desmume/src/wifi.cpp index f802a7162..a87ed525e 100644 --- a/desmume/src/wifi.cpp +++ b/desmume/src/wifi.cpp @@ -2046,7 +2046,14 @@ static pcap_if_t * WIFI_index_device(pcap_if_t *alldevs, int index) pcap_if_t *curr = alldevs; for(int i = 0; i < index; i++) + { + if (curr->next == NULL) + { + CommonSettings.wifi.infraBridgeAdapter = i; + break; + } curr = curr->next; + } WIFI_LOG(2, "SoftAP: using %s as device.\n", curr->PCAP_DEVICE_NAME); @@ -2064,7 +2071,7 @@ bool SoftAP_Init() char errbuf[PCAP_ERRBUF_SIZE]; pcap_if_t *alldevs; - int ret; + int ret = 0; ret = driver->PCAP_findalldevs(&alldevs, errbuf); if (ret == -1 || alldevs == NULL) diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 7bb44537d..017df5397 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -6143,7 +6143,14 @@ LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM cur = GetDlgItem(hDlg, IDC_BRIDGEADAPTER); for(i = 0, d = alldevs; d != NULL; i++, d = d->next) { - ComboBox_AddString(cur, d->description); + char buf[256] = {0}; + // on x64 description is empty + if (d->description[0] == 0) + strcpy(buf, d->name); + else + strcpy(buf, d->description); + + ComboBox_AddString(cur, buf); } ComboBox_SetCurSel(cur, CommonSettings.wifi.infraBridgeAdapter); }