wininet: Avoid a crash on NULL lpcszHeader in HttpSendRequestExW.

This commit is contained in:
Hans Leidekker 2009-11-17 15:59:52 +01:00 committed by Alexandre Julliard
parent bd4bc16147
commit 4990ca0ea3
1 changed files with 12 additions and 8 deletions

View File

@ -3338,17 +3338,21 @@ BOOL WINAPI HttpSendRequestExW(HINTERNET hRequest,
req = &workRequest.u.HttpSendRequestW;
if (lpBuffersIn)
{
DWORD size;
DWORD size = 0;
if (lpBuffersIn->dwHeadersLength == ~0u)
size = (strlenW( lpBuffersIn->lpcszHeader ) + 1) * sizeof(WCHAR);
else
size = lpBuffersIn->dwHeadersLength * sizeof(WCHAR);
if (lpBuffersIn->lpcszHeader)
{
if (lpBuffersIn->dwHeadersLength == ~0u)
size = (strlenW( lpBuffersIn->lpcszHeader ) + 1) * sizeof(WCHAR);
else
size = lpBuffersIn->dwHeadersLength * sizeof(WCHAR);
req->lpszHeader = HeapAlloc( GetProcessHeap(), 0, size );
memcpy( req->lpszHeader, lpBuffersIn->lpcszHeader, size );
req->lpszHeader = HeapAlloc( GetProcessHeap(), 0, size );
memcpy( req->lpszHeader, lpBuffersIn->lpcszHeader, size );
}
else req->lpszHeader = NULL;
req->dwHeaderLength = lpBuffersIn->dwHeadersLength;
req->dwHeaderLength = size / sizeof(WCHAR);
req->lpOptional = lpBuffersIn->lpvBuffer;
req->dwOptionalLength = lpBuffersIn->dwBufferLength;
req->dwContentLength = lpBuffersIn->dwBufferTotal;