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

Alexandre Julliard julliard at winehq.org
Tue Jun 2 05:08:18 CDT 2009


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



More information about the wine-devel mailing list