--- a/libpurple/network.c Wed Oct 19 13:00:17 2016 -0400
+++ b/libpurple/network.c Wed Oct 19 13:01:43 2016 -0400
@@ -636,17 +636,29 @@
WSAQUERYSET *res = (LPWSAQUERYSET) buf;
- DWORD size = sizeof(buf);
- while ((retval = WSALookupServiceNextA(h, 0, &size, res)) == ERROR_SUCCESS) {
- purple_debug_info("network", "found network '%s'\n",
- res->lpszServiceInstanceName ? res->lpszServiceInstanceName : "(NULL)");
+ DWORD current_size = 0; + DWORD size = current_size; + retval = WSALookupServiceNextA(h, 0, &size, res); + if (retval == ERROR_SUCCESS) { + purple_debug_info("network", "found network '%s'\n", + res->lpszServiceInstanceName ? res->lpszServiceInstanceName : "(NULL)"); + errorid = WSAGetLastError(); + if (errorid == WSAEFAULT) { + buf = g_realloc(buf, size); + res = (LPWSAQUERYSET) buf; - errorid = WSAGetLastError();
if (!(errorid == WSA_E_NO_MORE || errorid == WSAENOMORE)) {
gchar *msg = g_win32_error_message(errorid);
purple_debug_error("network", "got unexpected NLA response %s (%d)\n", msg, errorid);
@@ -700,9 +712,9 @@
time_t last_trigger = time(NULL) - 31;
WSAQUERYSET *res = (LPWSAQUERYSET) buf;
+ DWORD current_size = 0; if ((nla_event = WSACreateEvent()) == WSA_INVALID_EVENT) {
int errorid = WSAGetLastError();
@@ -794,13 +806,28 @@
- while ((retval = WSALookupServiceNextA(network_change_handle, 0, &size, res)) == ERROR_SUCCESS) {
- /*purple_timeout_add(0, _print_debug_msg,
+ DWORD size = current_size; + retval = WSALookupServiceNextA(network_change_handle, 0, &size, res); + if (retval == ERROR_SUCCESS) { + /*purple_timeout_add(0, _print_debug_msg, g_strdup_printf("thread found network '%s'\n",
res->lpszServiceInstanceName ? res->lpszServiceInstanceName : "(NULL)"));*/
+ int errorid = WSAGetLastError(); + if (errorid == WSAEFAULT) { + buf = g_realloc(buf, size); + res = (LPWSAQUERYSET) buf; WSAResetEvent(nla_event);
g_static_mutex_unlock(&mutex);