[PATCH 7/8] windowscodecs: Do not call png_read_end.

Esme Povirk esme at codeweavers.com
Fri Oct 9 14:56:22 CDT 2020


This isn't necessary because we do not use libpng to read metadata
or verify checksums. If this happens to be the last thing we do,
it will fail the pngformat tests which do not expect us to return
with the stream seeked to the end of the file.

Signed-off-by: Esme Povirk <esme at codeweavers.com>
---
 dlls/windowscodecs/libpng.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/dlls/windowscodecs/libpng.c b/dlls/windowscodecs/libpng.c
index 36151e94f1b..f101935211c 100644
--- a/dlls/windowscodecs/libpng.c
+++ b/dlls/windowscodecs/libpng.c
@@ -61,7 +61,6 @@ MAKE_FUNCPTR(png_get_io_ptr);
 MAKE_FUNCPTR(png_get_pHYs);
 MAKE_FUNCPTR(png_get_PLTE);
 MAKE_FUNCPTR(png_get_tRNS);
-MAKE_FUNCPTR(png_read_end);
 MAKE_FUNCPTR(png_read_image);
 MAKE_FUNCPTR(png_read_info);
 MAKE_FUNCPTR(png_set_bgr);
@@ -111,7 +110,6 @@ static void *load_libpng(void)
         LOAD_FUNCPTR(png_get_pHYs);
         LOAD_FUNCPTR(png_get_PLTE);
         LOAD_FUNCPTR(png_get_tRNS);
-        LOAD_FUNCPTR(png_read_end);
         LOAD_FUNCPTR(png_read_image);
         LOAD_FUNCPTR(png_read_info);
         LOAD_FUNCPTR(png_set_bgr);
@@ -183,7 +181,6 @@ HRESULT CDECL png_decoder_initialize(struct decoder *iface, IStream *stream, str
     struct png_decoder *This = impl_from_decoder(iface);
     png_structp png_ptr;
     png_infop info_ptr;
-    png_infop end_info;
     jmp_buf jmpbuf;
     HRESULT hr = E_FAIL;
     int color_type, bit_depth;
@@ -216,13 +213,6 @@ HRESULT CDECL png_decoder_initialize(struct decoder *iface, IStream *stream, str
         return E_FAIL;
     }
 
-    end_info = ppng_create_info_struct(png_ptr);
-    if (!end_info)
-    {
-        ppng_destroy_read_struct(&png_ptr, &info_ptr, NULL);
-        return E_FAIL;
-    }
-
     /* set up setjmp/longjmp error handling */
     if (setjmp(jmpbuf))
     {
@@ -443,7 +433,7 @@ HRESULT CDECL png_decoder_initialize(struct decoder *iface, IStream *stream, str
     free(row_pointers);
     row_pointers = NULL;
 
-    ppng_read_end(png_ptr, end_info);
+    /* png_read_end intentionally not called to not seek to the end of the file */
 
     st->flags = WICBitmapDecoderCapabilityCanDecodeAllImages |
                 WICBitmapDecoderCapabilityCanDecodeSomeImages |
@@ -455,7 +445,7 @@ HRESULT CDECL png_decoder_initialize(struct decoder *iface, IStream *stream, str
     hr = S_OK;
 
 end:
-    ppng_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+    ppng_destroy_read_struct(&png_ptr, &info_ptr, NULL);
     free(row_pointers);
     if (FAILED(hr))
     {
-- 
2.17.1




More information about the wine-devel mailing list