imagelist fix

Andreas Mohr a.mohr at mailto.de
Fri Apr 20 11:09:09 CDT 2001


Hi all,

fix off by one error in ImageList_DrawIndirect().
This fixes garbage icons in treeviews, for example.
(on Windows it doesn't display anything either in case of incorrect indices).
This fixes some SpyGuru treeview.

Also fixed some missing NULL HIMAGELIST check (fixes Microsoft Works startup).

Andreas Mohr
-------------- next part --------------
Determining best CVS host...
Using CVSROOT :pserver:cvs at rhlx01.fht-esslingen.de:/home/wine
Index: dlls/comctl32/imagelist.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/imagelist.c,v
retrieving revision 1.39
diff -u -r1.39 imagelist.c
--- dlls/comctl32/imagelist.c	2001/01/26 20:43:41	1.39
+++ dlls/comctl32/imagelist.c	2001/04/20 16:07:53
@@ -138,10 +138,10 @@
  *     nothing
  *
  * NOTES
- *     This functions is used by ImageList_DrawIndirect, when it is 
+ *     This function is used by ImageList_DrawIndirect, when it is 
  *     required to draw only the Image (without the mask) to the screen.
  *
- *     Blending and Overlays styles are accomplised by another function
+ *     Blending and Overlays styles are accomplished by another function
  */
 static VOID
 IMAGELIST_InternalDraw(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
@@ -164,27 +164,8 @@
 
 /*************************************************************************
  * IMAGELIST_InternalDrawMask [Internal] 
- *
- * Draws the image in the ImageList witht the mask
- *
- * PARAMS
- *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
- *     cx            [I] the width of the image to display
- *     cy............[I] the height of the image to display
- *
- * RETURNS
- *     nothing
- *
- * NOTES
- *     This functions is used by ImageList_DrawIndirect, when it is 
- *     required to draw the Image with the mask to the screen.
- *
- *     Blending and Overlays styles are accomplised by another function.
- */
-/*************************************************************************
- * IMAGELIST_InternalDrawMask [Internal] 
  *
- * Draws the image in the ImageList witht the mask
+ * Draws the image in the ImageList with the mask
  *
  * PARAMS
  *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
@@ -195,10 +176,10 @@
  *     nothing
  *
  * NOTES
- *     This functions is used by ImageList_DrawIndirect, when it is 
+ *     This function is used by ImageList_DrawIndirect, when it is 
  *     required to draw the Image with the mask to the screen.
  *
- *     Blending and Overlays styles are accomplised by another function.
+ *     Blending and Overlays styles are accomplished by another function.
  */
 static VOID
 IMAGELIST_InternalDrawMask(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
@@ -670,9 +651,9 @@
         The statement below should not be done in common practice
         but this is how ImageList_AddMasked works in Windows.
         It overwrites the original bitmap passed, this was discovered
-        by using the same bitmap to itterated the different styles
+        by using the same bitmap to iterate the different styles
         on windows where it failed (BUT ImageList_Add is OK)
-        This is here in case some apps really on this bug
+        This is here in case some apps rely on this bug
     */
     BitBlt(hdcBitmap, 
         0, 0, bmp.bmWidth, bmp.bmHeight,
@@ -788,7 +769,7 @@
  *
  * NOTES
  *     Copying from one image list to another is possible. The original
- *     implementation just copies or swapps within one image list.
+ *     implementation just copies or swaps within one image list.
  *     Could this feature become a bug??? ;-)
  */
 
@@ -1308,8 +1289,8 @@
         return FALSE;
     if (pimldp->himl == NULL)
         return FALSE;
-    if ((pimldp->i < 0) || (pimldp->i > pimldp->himl->cCurImage)) {
-	ERR("%d not within range (max %d)\n",pimldp->i,pimldp->himl->cCurImage);
+    if ((pimldp->i < 0) || (pimldp->i >= pimldp->himl->cCurImage)) {
+	ERR("%d not within range (max %d)\n",pimldp->i,pimldp->himl->cCurImage-1);
         return FALSE;
     }
     /*
@@ -1708,8 +1689,8 @@
  */
 
 HIMAGELIST WINAPI
-ImageList_LoadImageA (HINSTANCE hi, LPCSTR lpbmp, INT cx,	INT cGrow,
-			COLORREF clrMask, UINT uType,	UINT uFlags)
+ImageList_LoadImageA (HINSTANCE hi, LPCSTR lpbmp, INT cx, INT cGrow,
+			COLORREF clrMask, UINT uType, UINT uFlags)
 {
     HIMAGELIST himl = NULL;
     HANDLE   handle;
@@ -2169,6 +2150,11 @@
     HDC     hdcSrc, hdcDst;
     INT     cxNew, nCount;
 
+    if (himl == NULL) {
+        ERR("Invalid image list handle!\n");
+        return FALSE;
+    }
+    
     if ((i < -1) || (i >= himl->cCurImage)) {
         ERR("index out of range! %d\n", i);
         return FALSE;


More information about the wine-patches mailing list