In ImageList_Duplicate, ensure has_alpha array in destination image list is long enough

rmcdonald at bittorrent.com rmcdonald at bittorrent.com
Fri Jan 7 16:39:20 CST 2011


From: Robert McDonald <rmcdonald at bittorrent.com>

See bug # 25691 for justification for this patch.
---
 dlls/comctl32/imagelist.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index 2e1581e..8c4e45e 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -1521,6 +1521,19 @@ ImageList_Duplicate (HIMAGELIST himlSrc)
                     himlSrc->hdcMask, 0, 0, SRCCOPY);
 
 	himlDst->cCurImage = himlSrc->cCurImage;
+        if (himlSrc->has_alpha && himlDst->has_alpha
+            && himlSrc->cMaxImage > himlDst->cMaxImage)
+        {
+            /* ImageList_Create didn't create a long enough new_alpha */
+            char *new_alpha = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
+                himlDst->has_alpha, himlSrc->cMaxImage );
+            if (new_alpha) himlDst->has_alpha = new_alpha;
+            else
+            {
+                HeapFree( GetProcessHeap(), 0, himlDst->has_alpha );
+                himlDst->has_alpha = NULL;
+            }
+        }
 	himlDst->cMaxImage = himlSrc->cMaxImage;
         if (himlSrc->has_alpha && himlDst->has_alpha)
             memcpy( himlDst->has_alpha, himlSrc->has_alpha, himlDst->cCurImage );
-- 
1.7.1.GIT




More information about the wine-patches mailing list