ole32: Fix some leaks (coverity)
Frédéric Delanoy
frederic.delanoy at gmail.com
Mon Nov 19 08:53:25 CST 2012
CIDs 713614-713615 713618-713619
---
dlls/ole32/filemoniker.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/dlls/ole32/filemoniker.c b/dlls/ole32/filemoniker.c
index b3a5cc2..c5765df 100644
--- a/dlls/ole32/filemoniker.c
+++ b/dlls/ole32/filemoniker.c
@@ -968,10 +968,23 @@ FileMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** p
return nb1;
nb2=FileMonikerImpl_DecomposePath(pathOther,&stringTable2);
if (FAILED(nb2))
+ {
+ for(i=0;i<nb1;i++)
+ CoTaskMemFree(stringTable1[i]);
+ CoTaskMemFree(stringTable1);
return nb2;
+ }
if (nb1==0 || nb2==0)
+ {
+ for(i=0;i<nb1;i++)
+ CoTaskMemFree(stringTable1[i]);
+ CoTaskMemFree(stringTable1);
+ for(i=0;i<nb2;i++)
+ CoTaskMemFree(stringTable2[i]);
+ CoTaskMemFree(stringTable2);
return MK_E_NOPREFIX;
+ }
commonPath=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(min(lstrlenW(pathThis),lstrlenW(pathOther))+1));
if (!commonPath)
@@ -1139,10 +1152,17 @@ FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppm
return res;
len1=FileMonikerImpl_DecomposePath(str1,&tabStr1);
+ if (FAILED(len1))
+ return E_OUTOFMEMORY;
len2=FileMonikerImpl_DecomposePath(str2,&tabStr2);
- if (FAILED(len1) || FAILED(len2))
- return E_OUTOFMEMORY;
+ if (FAILED(len2))
+ {
+ for(j=0;j<len1;j++)
+ CoTaskMemFree(tabStr1[j]);
+ CoTaskMemFree(tabStr1);
+ return E_OUTOFMEMORY;
+ }
/* count the number of similar items from the begin of the two paths */
for(sameIdx=0; ( (tabStr1[sameIdx]!=NULL) &&
--
1.8.0
More information about the wine-patches
mailing list