winhttp: Fix a memory leak in insert_header (Valgrind).

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2017-03-24 15:49:19 +01:00 committed by Alexandre Julliard
parent c5d733e1ac
commit 08603e565b
1 changed files with 10 additions and 14 deletions

View File

@ -368,25 +368,21 @@ static int get_header_index( request_t *request, LPCWSTR field, int requested_in
static BOOL insert_header( request_t *request, header_t *header ) static BOOL insert_header( request_t *request, header_t *header )
{ {
DWORD count; DWORD count = request->num_headers + 1;
header_t *hdrs; header_t *hdrs;
count = request->num_headers + 1; if (request->headers)
if (count > 1)
hdrs = heap_realloc_zero( request->headers, sizeof(header_t) * count ); hdrs = heap_realloc_zero( request->headers, sizeof(header_t) * count );
else else
hdrs = heap_alloc_zero( sizeof(header_t) * count ); hdrs = heap_alloc_zero( sizeof(header_t) );
if (!hdrs) return FALSE;
if (hdrs) request->headers = hdrs;
{ request->headers[count - 1].field = strdupW( header->field );
request->headers = hdrs; request->headers[count - 1].value = strdupW( header->value );
request->headers[count - 1].field = strdupW( header->field ); request->headers[count - 1].is_request = header->is_request;
request->headers[count - 1].value = strdupW( header->value ); request->num_headers = count;
request->headers[count - 1].is_request = header->is_request; return TRUE;
request->num_headers++;
return TRUE;
}
return FALSE;
} }
static BOOL delete_header( request_t *request, DWORD index ) static BOOL delete_header( request_t *request, DWORD index )