Author: cfinck
Date: Wed Mar 16 16:46:37 2011
New Revision: 51069
URL:
http://svn.reactos.org/svn/reactos?rev=51069&view=rev
Log:
[SHELL32]
Thomas Faber
- Fix memory leak in RenderHDROP.
Modifications by me to have just a single return statement in the function.
See issue #5998 for more details.
Modified:
trunk/reactos/dll/win32/shell32/clipboard.c
Modified: trunk/reactos/dll/win32/shell32/clipboard.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/clipboar…
==============================================================================
--- trunk/reactos/dll/win32/shell32/clipboard.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/clipboard.c [iso-8859-1] Wed Mar 16 16:46:37 2011
@@ -49,15 +49,16 @@
UINT i;
int size = 0;
WCHAR wszFileName[MAX_PATH];
- HGLOBAL hGlobal;
+ HGLOBAL hGlobal = NULL;
DROPFILES *pDropFiles;
int offset;
LPITEMIDLIST *pidls;
TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
- pidls = HeapAlloc(GetProcessHeap(), 0, cidl * sizeof *pidls);
- if (!pidls) return NULL;
+ pidls = HeapAlloc(GetProcessHeap(), 0, cidl * sizeof(*pidls));
+ if (!pidls)
+ goto cleanup;
/* get the size needed */
size = sizeof(DROPFILES);
@@ -73,7 +74,8 @@
/* Fill the structure */
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
- if(!hGlobal) return hGlobal;
+ if(!hGlobal)
+ goto cleanup;
pDropFiles = (DROPFILES *)GlobalLock(hGlobal);
offset = (sizeof(DROPFILES) + sizeof(WCHAR) - 1) / sizeof(WCHAR);
@@ -91,7 +93,9 @@
((WCHAR*)pDropFiles)[offset] = 0;
GlobalUnlock(hGlobal);
- HeapFree(GetProcessHeap(), 0, pidls);
+cleanup:
+ if(pidls)
+ HeapFree(GetProcessHeap(), 0, pidls);
return hGlobal;
}