Commit in reactos/lib/shell32 on MAIN
iconcache.c+13-271.6 -> 1.7
Eric Pouech <pouech-eric@wanadoo.fr>
- GetModuleFileName[AW] doesn't terminate the string if the buffer is
  too small.
Jon Griffiths <jon_p_griffiths@yahoo.com>
- Don't leak cache imagelists on exit.

reactos/lib/shell32
iconcache.c 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- iconcache.c	27 Mar 2004 09:08:10 -0000	1.6
+++ iconcache.c	21 Sep 2004 20:48:02 -0000	1.7
@@ -102,7 +102,7 @@
 
 	lpsice = (LPSIC_ENTRY) SHAlloc (sizeof (SIC_ENTRY));
 
-	GetFullPathNameW(sSourceFile, MAX_PATH, path, NULL);
+       GetFullPathNameW(sSourceFile, MAX_PATH, path, NULL);
 	lpsice->sSourceFile = HeapAlloc( GetProcessHeap(), 0, (strlenW(path)+1)*sizeof(WCHAR) );
 	strcpyW( lpsice->sSourceFile, path );
 
@@ -211,29 +211,6 @@
 	LeaveCriticalSection(&SHELL32_SicCS);
 	return ret;
 }
-/****************************************************************************
- * SIC_GetIcon				[internal]
- *
- * NOTES
- *  retrieves the specified icon from the iconcache.
- */
-static HICON WINE_UNUSED SIC_GetIcon (LPCWSTR sSourceFile, INT dwSourceIndex, BOOL bSmallIcon )
-{	INT index;
-
-	TRACE("%s %i\n", debugstr_w(sSourceFile), dwSourceIndex);
-
-	index = SIC_GetIconIndex(sSourceFile, dwSourceIndex);
-
-	if (INVALID_INDEX == index)
-	{
-	  return (HICON)INVALID_INDEX;
-	}
-
-	if (bSmallIcon)
-	  return ImageList_GetIcon(ShellSmallIconList, index, ILD_NORMAL);
-
-	return ImageList_GetIcon(ShellBigIconList, index, ILD_NORMAL);
-}
 /*****************************************************************************
  * SIC_Initialize			[internal]
  *
@@ -309,10 +286,15 @@
 	if (sic_hdpa) DPA_DestroyCallback(sic_hdpa, sic_free, NULL );
 
 	sic_hdpa = NULL;
+	ImageList_Destroy(ShellSmallIconList);
+	ShellSmallIconList = 0;
+	ImageList_Destroy(ShellBigIconList);
+	ShellBigIconList = 0;
 
 	LeaveCriticalSection(&SHELL32_SicCS);
 	DeleteCriticalSection(&SHELL32_SicCS);
 }
+
 /*************************************************************************
  * Shell_GetImageList			[SHELL32.71]
  *
@@ -449,7 +431,7 @@
 
 /*************************************************************************
  * ExtractIconExW			[SHELL32.@]
- * RETURNS
+ * RETURNS
  *  0 no icon found
  *  -1 file is not valid
  *  or number of icons extracted
@@ -528,8 +510,12 @@
 	  else
 	    *lpiIcon = 6;   /* generic icon - found nothing */
 
-	  GetModuleFileNameA(hInst, lpIconPath, 0x80);
-	  hIcon = LoadIconA( hInst, MAKEINTRESOURCEA(*lpiIcon));
+	  if (GetModuleFileNameA(hInst, lpIconPath, 0x80))
+          {
+              /* terminate string (GetModuleFileName doesn't do if buffer is too small) */
+              lpIconPath[0x80 - 1] = '\0';
+              hIcon = LoadIconA( hInst, MAKEINTRESOURCEA(*lpiIcon));
+          }
 	}
 	return hIcon;
 }
CVSspam 0.2.8