[3/3] windowscodecs: Fixed loading png from streams

Viktor Semykin thesame.ml at gmail.com
Sun Mar 26 14:28:46 CDT 2017


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 at gmail.com>
---
 dlls/windowscodecs/pngformat.c | 7 +++----
 1 file changed, 3 insertions(+), 4 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;
-- 
2.11.1




More information about the wine-patches mailing list