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: Viktor Semykin <thesame.ml@gmail.com>
Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Viktor Semykin 2017-03-30 13:52:13 -03:00 committed by Alexandre Julliard
parent 5ada4e947e
commit 2d5c861f75
2 changed files with 4 additions and 5 deletions

View File

@ -774,11 +774,12 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
/* Find the metadata chunks in the file. */ /* Find the metadata chunks in the file. */
seek.QuadPart = 8; seek.QuadPart = 8;
hr = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, &chunk_start);
if (FAILED(hr)) goto end;
do 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); hr = read_png_chunk(pIStream, chunk_type, NULL, &chunk_size);
if (FAILED(hr)) goto end; 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 */ 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)); } while (memcmp(chunk_type, "IEND", 4));
This->stream = pIStream; This->stream = pIStream;

View File

@ -306,7 +306,7 @@ static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size
zero.QuadPart = 0; zero.QuadPart = 0;
IStream_Seek (stream, zero, STREAM_SEEK_CUR, &pos); 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); (UINT)(pos.QuadPart >> 32), (UINT)pos.QuadPart, image_size);
refcount = IStream_Release(stream); refcount = IStream_Release(stream);