[4/4] windowscodecs: Don't copy extra data from the end of a row.

Vincent Povirk madewokherd at gmail.com
Wed Jan 2 14:38:32 CST 2013


This could have broken a real application, if it allocates a buffer
that's too small to hold the last row.
-------------- next part --------------
From d95fdc3087402c5afb2d786a3c305d48a193e2e7 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Wed, 2 Jan 2013 14:12:27 -0600
Subject: [PATCH 4/4] windowscodecs: Don't copy extra data from the end of a
 row.

---
 dlls/windowscodecs/main.c         | 3 ++-
 dlls/windowscodecs/tests/bitmap.c | 5 +----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/dlls/windowscodecs/main.c b/dlls/windowscodecs/main.c
index 2898d97..b63edf5 100644
--- a/dlls/windowscodecs/main.c
+++ b/dlls/windowscodecs/main.c
@@ -86,7 +86,8 @@ HRESULT copy_pixels(UINT bpp, const BYTE *srcbuffer,
         return E_INVALIDARG;
 
     /* if the whole bitmap is copied and the buffer format matches then it's a matter of a single memcpy */
-    if (rc->X == 0 && rc->Y == 0 && rc->Width == srcwidth && rc->Height == srcheight && srcstride == dststride)
+    if (rc->X == 0 && rc->Y == 0 && rc->Width == srcwidth && rc->Height == srcheight &&
+        srcstride == dststride && srcstride == bytesperrow)
     {
         memcpy(dstbuffer, srcbuffer, srcstride * srcheight);
         return S_OK;
diff --git a/dlls/windowscodecs/tests/bitmap.c b/dlls/windowscodecs/tests/bitmap.c
index c6d3dda..811cbc7 100644
--- a/dlls/windowscodecs/tests/bitmap.c
+++ b/dlls/windowscodecs/tests/bitmap.c
@@ -493,10 +493,7 @@ static void test_CreateBitmapFromMemory(void)
     hr = IWICBitmap_CopyPixels(bitmap, NULL, 13, sizeof(data), data);
     ok(hr == S_OK, "IWICBitmap_CopyPixels error %#x\n", hr);
     for (i = 0; i < sizeof(data); i++)
-        if ((i % 13) < 9)
-            ok(data[i] == data3x2[i], "%u: expected %u, got %u\n", i, data3x2[i], data[i]);
-        else
-            todo_wine ok(data[i] == data3x2[i], "%u: expected %u, got %u\n", i, data3x2[i], data[i]);
+        ok(data[i] == data3x2[i], "%u: expected %u, got %u\n", i, data3x2[i], data[i]);
 
     rc.X = rc.Y = 0;
     rc.Width = 3;
-- 
1.8.0


More information about the wine-patches mailing list