=?UTF-8?Q?Andr=C3=A9=20Hentschel=20?=: shell32: Reorder code to avoid memory leaks (coverity).
Alexandre Julliard
julliard at winehq.org
Mon Oct 29 13:52:50 CDT 2012
Module: wine
Branch: master
Commit: b4b396a957290a0f7fffc36763e4f15c2d798e3b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b4b396a957290a0f7fffc36763e4f15c2d798e3b
Author: André Hentschel <nerv at dawncrow.de>
Date: Sun Oct 28 16:17:01 2012 +0100
shell32: Reorder code to avoid memory leaks (coverity).
---
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))
{
More information about the wine-cvs
mailing list