From 96ebd31066e704244131d1498d7805005e828a38 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Fri, 17 Jun 2005 09:52:33 +0000 Subject: [PATCH] ExtractAssociatedIconA needs to allocate enough space to have EAIW fill in lpIconPathW. --- dlls/shell32/iconcache.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dlls/shell32/iconcache.c b/dlls/shell32/iconcache.c index 96b88ef797c..bd109a1b602 100644 --- a/dlls/shell32/iconcache.c +++ b/dlls/shell32/iconcache.c @@ -640,7 +640,12 @@ HICON WINAPI ExtractAssociatedIconA(HINSTANCE hInst, LPSTR lpIconPath, LPWORD lp { HICON hIcon = NULL; INT len = MultiByteToWideChar(CP_ACP, 0, lpIconPath, -1, NULL, 0); - LPWSTR lpIconPathW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + /* Note that we need to allocate MAX_PATH, since we are supposed to fill + * the correct executable if there is no icon in lpIconPath directly. + * lpIconPath itself is supposed to be large enough, so make sure lpIconPathW + * is large enough too. Yes, I am puking too. + */ + LPWSTR lpIconPathW = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR)); TRACE("%p %s %p\n", hInst, debugstr_a(lpIconPath), lpiIcon); @@ -648,6 +653,7 @@ HICON WINAPI ExtractAssociatedIconA(HINSTANCE hInst, LPSTR lpIconPath, LPWORD lp { MultiByteToWideChar(CP_ACP, 0, lpIconPath, -1, lpIconPathW, len); hIcon = ExtractAssociatedIconW(hInst, lpIconPathW, lpiIcon); + WideCharToMultiByte(CP_ACP, 0, lpIconPathW, -1, lpIconPath, MAX_PATH , NULL, NULL); HeapFree(GetProcessHeap(), 0, lpIconPathW); } return hIcon;