Fwd: [1/3] wininet: Check for bad allocation in HeapReAlloc

Jason Green jave27 at gmail.com
Thu Jun 4 09:52:16 CDT 2009


Updated patch attached.


---------- Forwarded message ----------
From: Alexandre Julliard <julliard at winehq.org>
Date: Tue, Jun 2, 2009 at 6:08 AM
Subject: Re: [1/3] wininet: Check for bad allocation in HeapReAlloc
To: Jason Green <jave27 at gmail.com>
Cc: wine-devel at winehq.org


Jason Green <jave27 at gmail.com> writes:

> @@ -4213,10 +4213,10 @@ static INT HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr, BOOL clear)
>
>      /* regenerate raw headers */
>      while (cchRawHeaders + buflen + strlenW(szCrLf) > cchMaxRawHeaders)
> -    {
>          cchMaxRawHeaders *= 2;
> -        lpszRawHeaders = HeapReAlloc(GetProcessHeap(), 0, lpszRawHeaders, (cchMaxRawHeaders+1)*sizeof(WCHAR));
> -    }
> +    lpszRawHeaders = HeapReAlloc(GetProcessHeap(), 0, lpszRawHeaders, (cchMaxRawHeaders+1)*sizeof(WCHAR));
> +    if (lpszRawHeaders == NULL)
> +        goto lend;

If you are going to check the allocation, then you should handle the
error properly too instead of leaking memory.

--
Alexandre Julliard
julliard at winehq.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 01-check_bad_allocs.patch
Type: text/x-diff
Size: 2232 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20090604/12c83808/attachment-0001.patch>


More information about the wine-patches mailing list