From b9a24ae16e0cfc865924b974bc101e49623e606a Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Mon, 24 Jun 2019 00:22:53 +0000 Subject: [PATCH] wininet: Always set last error in InternetReadFile. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47352 Signed-off-by: Alistair Leslie-Hughes Signed-off-by: Alexandre Julliard (cherry picked from commit 8f5b9f4d4bf13cc95e809d9d7e9e24a96ea86878) Signed-off-by: Michael Stefaniuc --- dlls/wininet/internet.c | 3 +-- dlls/wininet/tests/http.c | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 246fdc99f4c..7bf9b52e528 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -2194,8 +2194,7 @@ BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer, TRACE("-- %s (%u) (bytes read: %d)\n", res == ERROR_SUCCESS ? "TRUE": "FALSE", res, pdwNumOfBytesRead ? *pdwNumOfBytesRead : -1); - if(res != ERROR_SUCCESS) - SetLastError(res); + SetLastError(res); return res == ERROR_SUCCESS; } diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index a113cec73df..990e0e880a6 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -984,7 +984,10 @@ static void InternetReadFile_chunked_test(void) { char *buffer = HeapAlloc(GetProcessHeap(),0,length+1); + SetLastError(0xdeadbeef); res = InternetReadFile(hor,buffer,length,&got); + ok(GetLastError() == 0 || + broken(GetLastError() == 0xdeadbeef /* XP/W2K3 */), "Last Error not reset %u\n", GetLastError()); buffer[got]=0; trace("ReadFile -> %i %i\n",res,got); @@ -997,8 +1000,11 @@ static void InternetReadFile_chunked_test(void) if (length == 0) { got = 0xdeadbeef; + SetLastError(0xdeadbeef); res = InternetReadFile( hor, buffer, 1, &got ); ok( res, "InternetReadFile failed: %u\n", GetLastError() ); + ok(GetLastError() == 0 || + broken(GetLastError() == 0xdeadbeef /* XP/W2K3 */), "Last Error not reset %u\n", GetLastError()); ok( !got, "got %u\n", got ); break; }