Commit 2d5c861f authored by Viktor Semykin's avatar Viktor Semykin Committed by Alexandre Julliard

windowscodecs: Fixed loading png from streams.

Png decoder was making one extra seek after it met IEND chunk. This led to crashes of some software. Signed-off-by: 's avatarViktor Semykin <thesame.ml@gmail.com> Signed-off-by: 's avatarVincent Povirk <vincent@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 5ada4e94
......@@ -774,11 +774,12 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
/* Find the metadata chunks in the file. */
seek.QuadPart = 8;
hr = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, &chunk_start);
if (FAILED(hr)) goto end;
do
{
hr = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, &chunk_start);
if (FAILED(hr)) goto end;
hr = read_png_chunk(pIStream, chunk_type, NULL, &chunk_size);
if (FAILED(hr)) goto end;
......@@ -816,8 +817,6 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
}
seek.QuadPart = chunk_start.QuadPart + chunk_size + 12; /* skip data and CRC */
hr = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, &chunk_start);
if (FAILED(hr)) goto end;
} while (memcmp(chunk_type, "IEND", 4));
This->stream = pIStream;
......
......@@ -306,7 +306,7 @@ static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size
zero.QuadPart = 0;
IStream_Seek (stream, zero, STREAM_SEEK_CUR, &pos);
todo_wine ok(pos.QuadPart < image_size, "seek beyond the end of stream: %x%08x >= %x\n",
ok(pos.QuadPart < image_size, "seek beyond the end of stream: %x%08x >= %x\n",
(UINT)(pos.QuadPart >> 32), (UINT)pos.QuadPart, image_size);
refcount = IStream_Release(stream);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment