From 8b628634198fc17344b5af81502dfd2109b2608d Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Fri, 15 Aug 2014 20:19:38 +0200 Subject: [PATCH] Don't crash when the HTTP request for getting the server status message fails. --- .../Sources/Plasma/Apps/plClient/winmain.cpp | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp index fe7fb7c1..da382767 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp @@ -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); + } } } }