From 815b532b6498e54acb30bc918af2301fe1bc5c94 Mon Sep 17 00:00:00 2001 From: David Hedberg Date: Wed, 30 Jul 2014 20:43:23 +0200 Subject: [PATCH] shell32: Always initialize shellitem to NULL in SHCreateShellItem. --- dlls/shell32/shellitem.c | 3 ++- dlls/shell32/tests/shlfolder.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dlls/shell32/shellitem.c b/dlls/shell32/shellitem.c index 82369758d48..06b07839fa3 100644 --- a/dlls/shell32/shellitem.c +++ b/dlls/shell32/shellitem.c @@ -555,6 +555,8 @@ HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent, TRACE("(%p,%p,%p,%p)\n", pidlParent, psfParent, pidl, ppsi); + *ppsi = NULL; + if (!pidl) { return E_INVALIDARG; @@ -604,7 +606,6 @@ HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent, } else { - *ppsi = NULL; ILFree(new_pidl); } return ret; diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c index 4e20251cd1c..acb351708f4 100644 --- a/dlls/shell32/tests/shlfolder.c +++ b/dlls/shell32/tests/shlfolder.c @@ -2236,8 +2236,10 @@ static void test_SHCreateShellItem(void) pidl_abstestfile = pILCombine(pidl_cwd, pidl_testfile); + shellitem = (void*)0xdeadbeef; ret = pSHCreateShellItem(NULL, NULL, NULL, &shellitem); ok(ret == E_INVALIDARG, "SHCreateShellItem returned %x\n", ret); + ok(shellitem == 0, "Got %p\n", shellitem); if (0) /* crashes on Windows XP */ {