[PATCH] windowscodecs: Fix data corruption for Adobe JPEGs

Anton Romanov theli.ua at gmail.com
Sat Feb 3 01:46:02 CST 2018


Loop to invert CMYK goes through all data within loop that goes over
rows, going over the same data multiple times.

Signed-off-by: Anton Romanov <theli.ua at gmail.com>
---
 dlls/windowscodecs/jpegformat.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/dlls/windowscodecs/jpegformat.c b/dlls/windowscodecs/jpegformat.c
index ef050ba688..8a5532d2c1 100644
--- a/dlls/windowscodecs/jpegformat.c
+++ b/dlls/windowscodecs/jpegformat.c
@@ -603,6 +603,8 @@ static HRESULT WINAPI JpegDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface,
     UINT max_row_needed;
     jmp_buf jmpbuf;
     WICRect rect;
+    UINT i;
+
     TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
 
     if (!prc)
@@ -678,13 +680,13 @@ static HRESULT WINAPI JpegDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface,
                 This->cinfo.output_width, This->cinfo.output_scanline - first_scanline,
                 stride);
         }
-
-        if (This->cinfo.out_color_space == JCS_CMYK && This->cinfo.saw_Adobe_marker)
-            /* Adobe JPEG's have inverted CMYK data. */
-            for (i=0; i<data_size; i++)
-                This->image_data[i] ^= 0xff;
     }
 
+    if (This->cinfo.out_color_space == JCS_CMYK && This->cinfo.saw_Adobe_marker)
+        /* Adobe JPEG's have inverted CMYK data. */
+        for (i=0; i<data_size; i++)
+            This->image_data[i] ^= 0xff;
+
     LeaveCriticalSection(&This->lock);
 
     return copy_pixels(bpp, This->image_data,
-- 
2.16.1




More information about the wine-devel mailing list