-- v2: wininet: Simplify memory allocation in HTTP_InsertCustomHeader.
From: Alex Henrie alexhenrie24@gmail.com
--- dlls/wininet/http.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 18f61f108fc..b42f823208c 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -6280,15 +6280,7 @@ static DWORD HTTP_InsertCustomHeader(http_request_t *request, LPHTTPHEADERW lpHd
TRACE("--> %s: %s\n", debugstr_w(lpHdr->lpszField), debugstr_w(lpHdr->lpszValue)); count = request->nCustHeaders + 1; - if (count > 1) - { - lph = realloc(request->custHeaders, sizeof(HTTPHEADERW) * count); - memset(lph + request->nCustHeaders, 0, sizeof(HTTPHEADERW)); - } - else - { - lph = calloc(count, sizeof(HTTPHEADERW)); - } + lph = realloc(request->custHeaders, sizeof(HTTPHEADERW) * count);
if (!lph) return ERROR_OUTOFMEMORY;
On Mon Nov 28 15:45:10 2022 +0000, Alex Henrie wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/1562/diffs?diff_id=21355&start_sha=483b34e3c871ec3f8457898dcedfd7332ee961f3#5257c8cfe2c57bd3f642ff218718644d33ec40ef_6284_6284)
You're absolutely right that I accidentally broke out-of-memory handling here, and I didn't notice that the memset is not actually necessary at all in this function. I have submitted a new version that doesn't call memset. Thank you for your careful review.
This merge request was approved by Jacek Caban.