ole32: Don't leak memory allocated by FileMonikerImpl_DecomposePath (coverity)

André Hentschel nerv at dawncrow.de
Sun Oct 28 10:16:43 CDT 2012


CID 713616 & 713617
---
 dlls/ole32/filemoniker.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/dlls/ole32/filemoniker.c b/dlls/ole32/filemoniker.c
index 20c0870..34e4b76 100644
--- a/dlls/ole32/filemoniker.c
+++ b/dlls/ole32/filemoniker.c
@@ -711,8 +711,10 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
         /* the length of the composed path string  is raised by the sum of the two paths lengths  */
         newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1));
 
-	  if (newStr==NULL)
-		return E_OUTOFMEMORY;
+        if (newStr==NULL) {
+            res = E_OUTOFMEMORY;
+            goto cleanup;
+        }
 
         /* new path is the concatenation of the rest of str1 and str2 */
         for(*newStr=0,j=0;j<=lastIdx1;j++)
@@ -730,6 +732,7 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
         /* free all strings space memory used by this function */
         HeapFree(GetProcessHeap(),0,newStr);
 
+cleanup:
         for(i=0; strDec1[i]!=NULL;i++)
             CoTaskMemFree(strDec1[i]);
         for(i=0; strDec2[i]!=NULL;i++)
-- 
1.8.0



-- 

Best Regards, André Hentschel


More information about the wine-patches mailing list