Vincent Povirk : shell32: Handle NULL return icon parameters in SHDefExtractIcon.
Alexandre Julliard
julliard at winehq.org
Mon May 18 08:13:13 CDT 2009
Module: wine
Branch: master
Commit: e083dc831cdcb7424ba00e69e0ab1e022053a72f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e083dc831cdcb7424ba00e69e0ab1e022053a72f
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Fri May 15 15:16:35 2009 -0500
shell32: Handle NULL return icon parameters in SHDefExtractIcon.
---
dlls/shell32/iconcache.c | 10 ++++++++--
dlls/shell32/tests/shelllink.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/dlls/shell32/iconcache.c b/dlls/shell32/iconcache.c
index 6ef5d8e..b51ff06 100644
--- a/dlls/shell32/iconcache.c
+++ b/dlls/shell32/iconcache.c
@@ -817,8 +817,14 @@ HRESULT WINAPI SHDefExtractIconW(LPCWSTR pszIconFile, int iIndex, UINT uFlags,
if (ret == 0xFFFFFFFF)
return E_FAIL;
if (ret > 0) {
- *phiconLarge = hIcons[0];
- *phiconSmall = hIcons[1];
+ if (phiconLarge)
+ *phiconLarge = hIcons[0];
+ else
+ DestroyIcon(hIcons[0]);
+ if (phiconSmall)
+ *phiconSmall = hIcons[1];
+ else
+ DestroyIcon(hIcons[1]);
return S_OK;
}
return S_FALSE;
diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c
index 9e792fd..3ab3766 100644
--- a/dlls/shell32/tests/shelllink.c
+++ b/dlls/shell32/tests/shelllink.c
@@ -40,10 +40,12 @@
typedef void (WINAPI *fnILFree)(LPITEMIDLIST);
typedef BOOL (WINAPI *fnILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST);
typedef HRESULT (WINAPI *fnSHILCreateFromPath)(LPCWSTR, LPITEMIDLIST *,DWORD*);
+typedef HRESULT (WINAPI *fnSHDefExtractIconA)(LPCSTR, int, UINT, HICON*, HICON*, UINT);
static fnILFree pILFree;
static fnILIsEqual pILIsEqual;
static fnSHILCreateFromPath pSHILCreateFromPath;
+static fnSHDefExtractIconA pSHDefExtractIconA;
static DWORD (WINAPI *pGetLongPathNameA)(LPCSTR, LPSTR, DWORD);
@@ -708,6 +710,34 @@ static void test_datalink(void)
IShellLinkW_Release( sl );
}
+static void test_shdefextracticon(void)
+{
+ HICON hiconlarge=NULL, hiconsmall=NULL;
+ HRESULT res;
+
+ if (!pSHDefExtractIconA)
+ {
+ win_skip("SHDefExtractIconA is unavailable\n");
+ return;
+ }
+
+ res = pSHDefExtractIconA("shell32.dll", 0, 0, &hiconlarge, &hiconsmall, MAKELONG(16,24));
+ ok(SUCCEEDED(res), "SHDefExtractIconA failed, res=%x\n", res);
+ ok(hiconlarge != NULL, "got null hiconlarge\n");
+ ok(hiconsmall != NULL, "got null hiconsmall\n");
+ DestroyIcon(hiconlarge);
+ DestroyIcon(hiconsmall);
+
+ hiconsmall = NULL;
+ res = pSHDefExtractIconA("shell32.dll", 0, 0, NULL, &hiconsmall, MAKELONG(16,24));
+ ok(SUCCEEDED(res), "SHDefExtractIconA failed, res=%x\n", res);
+ ok(hiconsmall != NULL, "got null hiconsmall\n");
+ DestroyIcon(hiconsmall);
+
+ res = pSHDefExtractIconA("shell32.dll", 0, 0, NULL, NULL, MAKELONG(16,24));
+ ok(SUCCEEDED(res), "SHDefExtractIconA failed, res=%x\n", res);
+}
+
START_TEST(shelllink)
{
HRESULT r;
@@ -717,6 +747,7 @@ START_TEST(shelllink)
pILFree = (fnILFree) GetProcAddress(hmod, (LPSTR)155);
pILIsEqual = (fnILIsEqual) GetProcAddress(hmod, (LPSTR)21);
pSHILCreateFromPath = (fnSHILCreateFromPath) GetProcAddress(hmod, (LPSTR)28);
+ pSHDefExtractIconA = (fnSHDefExtractIconA) GetProcAddress(hmod, "SHDefExtractIconA");
pGetLongPathNameA = (void *)GetProcAddress(hkernel32, "GetLongPathNameA");
@@ -728,6 +759,7 @@ START_TEST(shelllink)
test_get_set();
test_load_save();
test_datalink();
+ test_shdefextracticon();
CoUninitialize();
}
More information about the wine-cvs
mailing list