Viktor Semykin : windowscodecs: Fixed loading png from streams.
Module: wine Branch: master Commit: 2d5c861f750eea985a45c726f31576d941e824e4 URL: http://source.winehq.org/git/wine.git/?a=commit;h=2d5c861f750eea985a45c726f3... Author: Viktor Semykin <thesame.ml(a)gmail.com> Date: Thu Mar 30 13:52:13 2017 -0300 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(a)gmail.com> Signed-off-by: Vincent Povirk <vincent(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/windowscodecs/pngformat.c | 7 +++---- dlls/windowscodecs/tests/pngformat.c | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c index 990dcf6..c98a6a7 100644 --- a/dlls/windowscodecs/pngformat.c +++ b/dlls/windowscodecs/pngformat.c @@ -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; diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c index e9a0c18..02e0b1c 100644 --- a/dlls/windowscodecs/tests/pngformat.c +++ b/dlls/windowscodecs/tests/pngformat.c @@ -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);
participants (1)
-
Alexandre Julliard