shell32: Reorder code to avoid memory leaks (coverity)
André Hentschel
nerv at dawncrow.de
Sun Oct 28 10:17:01 CDT 2012
CID 713697 & 713698 & 713700 & 713703
---
dlls/shell32/brsfolder.c | 6 +++---
dlls/shell32/pidl.c | 3 ++-
dlls/shell32/shelldispatch.c | 2 +-
dlls/shell32/shellpath.c | 3 +++
4 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/dlls/shell32/brsfolder.c b/dlls/shell32/brsfolder.c
index 3200051..0e7b9d3 100644
--- a/dlls/shell32/brsfolder.c
+++ b/dlls/shell32/brsfolder.c
@@ -369,11 +369,11 @@ static HTREEITEM InsertTreeViewItem( browse_info *info, IShellFolder * lpsf,
tvi.cChildren= pEnumIL ? 1 : 0;
tvi.mask |= TVIF_CHILDREN;
- lptvid = SHAlloc( sizeof(TV_ITEMDATA) );
- if (!lptvid)
+ if (!GetName(lpsf, pidl, SHGDN_NORMAL, szBuff))
return NULL;
- if (!GetName(lpsf, pidl, SHGDN_NORMAL, szBuff))
+ lptvid = SHAlloc( sizeof(TV_ITEMDATA) );
+ if (!lptvid)
return NULL;
tvi.pszText = szBuff;
diff --git a/dlls/shell32/pidl.c b/dlls/shell32/pidl.c
index 58b8104..a712504 100644
--- a/dlls/shell32/pidl.c
+++ b/dlls/shell32/pidl.c
@@ -2503,10 +2503,11 @@ LPITEMIDLIST* _ILCopyaPidl(const LPCITEMIDLIST * apidlsrc, UINT cidl)
UINT i;
LPITEMIDLIST *apidldest;
- apidldest = SHAlloc(cidl * sizeof(LPITEMIDLIST));
if (!apidlsrc)
return NULL;
+ apidldest = SHAlloc(cidl * sizeof(LPITEMIDLIST));
+
for (i = 0; i < cidl; i++)
apidldest[i] = ILClone(apidlsrc[i]);
diff --git a/dlls/shell32/shelldispatch.c b/dlls/shell32/shelldispatch.c
index 825c405..65237ef 100644
--- a/dlls/shell32/shelldispatch.c
+++ b/dlls/shell32/shelldispatch.c
@@ -1061,7 +1061,7 @@ static HRESULT WINAPI ShellDispatch_IsServiceRunning(IShellDispatch2 *iface, BST
if (!service)
{
ERR("Failed to open service %s (%u)\n", debugstr_w(name), GetLastError());
- CloseServiceHandle(service);
+ CloseServiceHandle(scm);
return S_OK;
}
diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c
index e607149..6fdd762 100644
--- a/dlls/shell32/shellpath.c
+++ b/dlls/shell32/shellpath.c
@@ -3790,7 +3790,10 @@ static BOOL is_knownfolder( struct foldermanager *fm, const KNOWNFOLDERID *id )
hr = get_known_folder_registry_path(id, NULL, ®istryPath);
if(SUCCEEDED(hr))
+ {
hr = HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE, registryPath, 0, 0, &hKey));
+ HeapFree(GetProcessHeap(), 0, registryPath);
+ }
if(SUCCEEDED(hr))
{
--
1.8.0
--
Best Regards, André Hentschel
More information about the wine-patches
mailing list