1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 10:52:46 +00:00

Merged in cwalther/cwe/statusmessagecrash (pull request #31)

Don't crash when the HTTP request for getting the server status message fails

This fixes the crash that keeps Windows 7 users out of the game when support.cyanworlds.com is down, reported with some regularity e.g. at http://mystonline.com/forums/viewtopic.php?f=40&t=27352 .

Apparently on Windows 7, unlike on Windows XP and contrary to its documentation, WinHttpReadData() does not zero its lpdwNumberOfBytesRead argument when called with an invalid request, so the lack of error checking here bites.
This commit is contained in:
Christian Walther
2015-04-03 23:07:05 +02:00

View File

@ -1250,20 +1250,24 @@ void StatusCallback(void *param)
{
static char data[256] = {0};
DWORD bytesRead;
WinHttpSendRequest(
hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS,
0,
WINHTTP_NO_REQUEST_DATA,
0,
0,
0
);
WinHttpReceiveResponse(hRequest, 0);
WinHttpReadData(hRequest, data, 255, &bytesRead);
data[bytesRead] = 0;
if(bytesRead)
if(
WinHttpSendRequest(
hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS,
0,
WINHTTP_NO_REQUEST_DATA,
0,
0,
0
)
&& WinHttpReceiveResponse(hRequest, 0)
&& WinHttpReadData(hRequest, data, 255, &bytesRead)
&& bytesRead
)
{
data[bytesRead] = 0;
PostMessage(hwnd, WM_USER_SETSTATUSMSG, 0, (LPARAM) data);
}
}
}
}