diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 53597944a99..e192592693a 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -2280,7 +2280,7 @@ BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer, TRACE("(%p %p 0x%x 0x%lx)\n", hFile, lpBuffer, dwFlags, dwContext); - if (lpBuffer->dwStructSize != sizeof(*lpBuffer)) { + if (!lpBuffer || lpBuffer->dwStructSize != sizeof(*lpBuffer)) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index b4cad7d15ba..78cec504564 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -1067,6 +1067,11 @@ static void InternetReadFileExA_test(int flags) CLEAR_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER); CLEAR_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER); + rc = InternetReadFileExW(hor, NULL, 0, 0xdeadcafe); + ok(!rc && (GetLastError() == ERROR_INVALID_PARAMETER), + "InternetReadFileEx should have failed with ERROR_INVALID_PARAMETER instead of %s, %u\n", + rc ? "TRUE" : "FALSE", GetLastError()); + /* tests invalid dwStructSize */ inetbuffers.dwStructSize = sizeof(inetbuffers)+1; inetbuffers.lpcszHeader = NULL;