diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 5a097058e47..31ba58b50e8 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -1099,14 +1099,12 @@ BOOL WINAPI InternetGetLastResponseInfoA(LPDWORD lpdwError, return FALSE; } *lpdwError = lpwite->dwError; - if (lpwite->dwError && *lpdwBufferLength) + if (*lpdwBufferLength) { memcpy(lpszBuffer, lpwite->response, *lpdwBufferLength); lpszBuffer[*lpdwBufferLength - 1] = 0; *lpdwBufferLength = strlen(lpszBuffer); } - else - *lpdwBufferLength = 0; } else { @@ -1148,13 +1146,11 @@ BOOL WINAPI InternetGetLastResponseInfoW(LPDWORD lpdwError, return FALSE; } *lpdwError = lpwite->dwError; - if (lpwite->dwError && *lpdwBufferLength) + if (*lpdwBufferLength) { MultiByteToWideChar(CP_ACP, 0, lpwite->response, -1, lpszBuffer, *lpdwBufferLength); *lpdwBufferLength = lstrlenW(lpszBuffer); } - else - *lpdwBufferLength = 0; } else { diff --git a/dlls/wininet/tests/ftp.c b/dlls/wininet/tests/ftp.c index 16fbbcb2ed3..c7c4febf379 100644 --- a/dlls/wininet/tests/ftp.c +++ b/dlls/wininet/tests/ftp.c @@ -706,6 +706,8 @@ static void test_command(HINTERNET hFtp) BOOL ret; DWORD error; unsigned int i; + BOOL had_error_zero = FALSE; + BOOL had_error_zero_size_positive = FALSE; static const struct { BOOL ret; @@ -776,8 +778,12 @@ static void test_command(HINTERNET hFtp) ret = InternetGetLastResponseInfoA(&error, buffer, &size); ok(ret, "%d: got ret %d\n", i, ret); ok(size == 0 || strlen(buffer) == size, "%d: size %d, buffer size %d\n", i, size, size ? strlen(buffer) : 0); + had_error_zero |= (error == 0); + had_error_zero_size_positive |= (error == 0 && size > 0); HeapFree(GetProcessHeap(), 0, buffer); } + + ok(!had_error_zero || had_error_zero_size_positive, "never observed error 0 with positive size\n"); } static void test_find_first_file(HINTERNET hFtp, HINTERNET hConnect)