[PATCH] GetUrlCacheEntryInfo*: Handle null dest pointer when length is given

Rob Shearman robertshearman at gmail.com
Fri Jun 6 07:03:05 CDT 2008


2008/6/6 Jon Griffiths <jon_p_griffiths at yahoo.com>:
> -    if (dwRequiredSize > *lpdwBufferSize)
> -    {
> -        *lpdwBufferSize = dwRequiredSize;
> +    ret = dwRequiredSize > *lpdwBufferSize? FALSE : TRUE;
> +    *lpdwBufferSize = dwRequiredSize;
> +
> +    if (!ret)
>          SetLastError(ERROR_INSUFFICIENT_BUFFER);
> -        return FALSE;
> +    else if (!lpCacheEntryInfo)
> +    {
> +        SetLastError(ERROR_INVALID_PARAMETER);
> +        ret = FALSE;
>      }
> -    *lpdwBufferSize = dwRequiredSize;
> -    return TRUE;
> +    return ret;
>  }

Internal functions should return an error code instead of calling
SetLastError. This avoids situations like this:

> @@ -1531,6 +1539,9 @@ BOOL WINAPI GetUrlCacheEntryInfoA(
>              FALSE /* ANSI */))
>          {
>              URLCacheContainer_UnlockIndex(pContainer, pHeader);
> +            /* This case is inconsistent w.r.t RetrieveUrlCacheEntryFile */
> +            if (!lpCacheEntryInfo && GetLastError() == ERROR_INVALID_PARAMETER)
> +                SetLastError(ERROR_INSUFFICIENT_BUFFER);
>              return FALSE;
>          }
>          TRACE("Local File Name: %s\n", debugstr_a(lpCacheEntryInfo->lpszLocalFileName));


-- 
Rob Shearman



More information about the wine-devel mailing list