shell32: make sure BrowseForFolder doesn't return NULL for the
Desktop folder as this means a cancel (should fix bug #5533)
Mikołaj Zalewski
mikolaj at zalewski.pl
Wed Feb 7 06:27:15 CST 2007
-------------- next part --------------
From dae3d68d6c303cdc54e398646c7104271cda0d6b Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miko=C5=82aj_Zalewski?= <mikolaj at zalewski.pl>
Date: Wed, 7 Feb 2007 13:22:38 +0100
Subject: [PATCH] shell32: make sure BrowseForFolder doesn't return NULL for the Desktop folder as this means a cancel
---
dlls/shell32/brsfolder.c | 4 +++-
dlls/shell32/pidl.c | 17 +++++++++++++++++
dlls/shell32/pidl.h | 2 ++
3 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/dlls/shell32/brsfolder.c b/dlls/shell32/brsfolder.c
index 666e34b..3943117 100644
--- a/dlls/shell32/brsfolder.c
+++ b/dlls/shell32/brsfolder.c
@@ -524,7 +524,9 @@ static BOOL BrsFolder_OnCommand( browse_info *info, UINT id )
switch (id)
{
case IDOK:
- info->pidlRet = ILClone(info->pidlRet); /* The original pidl will be free'd. */
+ /* The original pidl is owned by the treeview and will be freed */
+ info->pidlRet = ILClone(info->pidlRet);
+ _ILMakePidlNotNull(&info->pidlRet); /* a NULL would mean a cancel */
pdump( info->pidlRet );
if (lpBrowseInfo->pszDisplayName)
SHGetPathFromIDListW( info->pidlRet, lpBrowseInfo->pszDisplayName );
diff --git a/dlls/shell32/pidl.c b/dlls/shell32/pidl.c
index 97cf051..0582db6 100644
--- a/dlls/shell32/pidl.c
+++ b/dlls/shell32/pidl.c
@@ -2264,3 +2264,20 @@ LPITEMIDLIST* _ILCopyCidaToaPidl(LPITEMIDLIST* pidl, LPIDA cida)
return dst;
}
+
+
+/*************************************************************************
+ * _ILMakePidlNotNull
+ *
+ * A null pidl is a valid pidl that represents the Desktop. However if we don't
+ * want a NULL pidl (e.g. because NULL indicates an error) this function will
+ * make an explicit empty pidl if the parameter is NULL.
+ */
+HRESULT _ILMakePidlNotNull(LPITEMIDLIST *pidl)
+{
+ if (*pidl == NULL)
+ *pidl = _ILCreateDesktop();
+ if (*pidl == NULL)
+ return E_OUTOFMEMORY;
+ return S_OK;
+}
diff --git a/dlls/shell32/pidl.h b/dlls/shell32/pidl.h
index 0bdae80..f199adc 100644
--- a/dlls/shell32/pidl.h
+++ b/dlls/shell32/pidl.h
@@ -281,4 +281,6 @@ LPITEMIDLIST * _ILCopyCidaToaPidl(LPITEMIDLIST* pidl, LPIDA cida);
BOOL WINAPI ILGetDisplayNameExA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPSTR path, DWORD type);
BOOL WINAPI ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type);
+HRESULT _ILMakePidlNotNull(LPITEMIDLIST *pidl);
+
#endif
--
1.4.4.2
More information about the wine-patches
mailing list