[PATCH v4 2/5] ole32: Add support for loading dibs from presentation streams to data cache.

Dmitry Timoshkov dmitry at baikal.ru
Thu Apr 5 21:37:45 CDT 2018


Sergio Gómez Del Real <sdelreal at codeweavers.com> wrote:

> +    if (cache_entry->load_stream_num != STREAM_NUMBER_CONTENTS)
> +    {
> +        hr = read_clipformat( stm, &cf );
> +        if (FAILED( hr )) return hr;
> +        hr = IStream_Read( stm, &pres, sizeof(pres), &read );
> +        if (FAILED( hr ) || read != sizeof(pres)) return E_FAIL;
> +    }
> +    else
> +    {
> +        hr = IStream_Read( stm, &file, sizeof(BITMAPFILEHEADER), &read );
> +        if (FAILED( hr ) || read != sizeof(BITMAPFILEHEADER)) return E_FAIL;
> +    }

Checking for S_OK in all tests above should be enough. That also should help
with deciding a return value on failure.

> +
> +    hr = IStream_Seek( stm, offset_zero, STREAM_SEEK_CUR, &current_pos );
> +    if (FAILED( hr )) return hr;
> +    stat.cbSize.QuadPart -= current_pos.QuadPart;
>  
>      hglobal = GlobalAlloc( GMEM_MOVEABLE, stat.cbSize.u.LowPart );
>      if (!hglobal) return E_OUTOFMEMORY;
>      dib = GlobalLock( hglobal );
>  
> +    /* read first DWORD of BITMAPINFOHEADER */
>      hr = IStream_Read( stm, dib, sizeof(DWORD), &read );
>      if (hr != S_OK || read != sizeof(DWORD)) goto fail;

While you are at it the check above could also be simplified.

>      bi_size = *(DWORD *)dib;
>      if (stat.cbSize.QuadPart < bi_size) goto fail;
>  
> -    hr = IStream_Read( stm, (char *)dib + sizeof(DWORD), bi_size - sizeof(DWORD), &read );
> +    /* read rest of BITMAPINFOHEADER */
> +    hr = IStream_Read( stm, dib + sizeof(DWORD), bi_size - sizeof(DWORD), &read );
>      if (hr != S_OK || read != bi_size - sizeof(DWORD)) goto fail;

Same here.

> -    info_size = bitmap_info_size( dib, DIB_RGB_COLORS );
> +    info_size = bitmap_info_size( (BITMAPINFO *)dib, DIB_RGB_COLORS );
>      if (stat.cbSize.QuadPart < info_size) goto fail;
>      if (info_size > bi_size)
>      {
> -        hr = IStream_Read( stm, (char *)dib + bi_size, info_size - bi_size, &read );
> +        hr = IStream_Read( stm, dib + bi_size, info_size - bi_size, &read );
>          if (hr != S_OK || read != info_size - bi_size) goto fail;

Here, and other similar places.

-- 
Dmitry.



More information about the wine-devel mailing list