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

oldstable
André Hentschel 2012-10-28 16:16:43 +01:00 committed by Alexandre Julliard
parent 764011a94f
commit c223354912
1 changed files with 15 additions and 14 deletions

View File

@ -711,24 +711,25 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
/* the length of the composed path string is raised by the sum of the two paths lengths */ /* 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)); newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1));
if (newStr==NULL) if (newStr)
return E_OUTOFMEMORY; {
/* new path is the concatenation of the rest of str1 and str2 */
for(*newStr=0,j=0;j<=lastIdx1;j++)
strcatW(newStr,strDec1[j]);
/* new path is the concatenation of the rest of str1 and str2 */ if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || lstrcmpW(strDec2[i],bkSlash)!=0)
for(*newStr=0,j=0;j<=lastIdx1;j++) strcatW(newStr,bkSlash);
strcatW(newStr,strDec1[j]);
if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || lstrcmpW(strDec2[i],bkSlash)!=0) for(j=i;j<=lastIdx2;j++)
strcatW(newStr,bkSlash); strcatW(newStr,strDec2[j]);
for(j=i;j<=lastIdx2;j++) /* create a new moniker with the new string */
strcatW(newStr,strDec2[j]); res=CreateFileMoniker(newStr,ppmkComposite);
/* create a new moniker with the new string */ /* free all strings space memory used by this function */
res=CreateFileMoniker(newStr,ppmkComposite); HeapFree(GetProcessHeap(),0,newStr);
}
/* free all strings space memory used by this function */ else res = E_OUTOFMEMORY;
HeapFree(GetProcessHeap(),0,newStr);
for(i=0; strDec1[i]!=NULL;i++) for(i=0; strDec1[i]!=NULL;i++)
CoTaskMemFree(strDec1[i]); CoTaskMemFree(strDec1[i]);