- fixes two leaks in file- and itemmoniker
Index: wine/dlls/ole32/itemmoniker.c =================================================================== RCS file: /home/wine/wine/dlls/ole32/itemmoniker.c,v retrieving revision 1.13 diff -d -u -r1.13 itemmoniker.c --- wine/dlls/ole32/itemmoniker.c 31 May 2002 23:25:50 -0000 1.13 +++ wine/dlls/ole32/itemmoniker.c 14 Jul 2002 20:38:49 -0000 @@ -387,20 +387,20 @@ This->itemName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr1+1)); if (!This->itemName) return E_OUTOFMEMORY; - strcpyW(This->itemName,lpszItem); + lstrcpyW(This->itemName,lpszItem); if (!lpszDelim) FIXME("lpszDelim is NULL. Using empty string which is possibly wrong.\n"); delim = lpszDelim ? lpszDelim : emptystr; - sizeStr2=strlenW(delim); + sizeStr2=lstrlenW(delim); This->itemDelimiter=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr2+1)); if (!This->itemDelimiter) { HeapFree(GetProcessHeap(),0,This->itemName); return E_OUTOFMEMORY; } - strcpyW(This->itemDelimiter,delim); + lstrcpyW(This->itemDelimiter,delim); return S_OK; } @@ -611,32 +611,28 @@ CLSID clsid; LPOLESTR dispName1,dispName2; IBindCtx* bind; - HRESULT res; + HRESULT res = S_FALSE; TRACE("(%p,%p)\n",iface,pmkOtherMoniker); - if (pmkOtherMoniker==NULL) - return S_FALSE; - - /* This method returns S_OK if both monikers are item monikers and their display names are */ - /* identical (using a case-insensitive comparison); otherwise, the method returns S_FALSE. */ - - IMoniker_GetClassID(pmkOtherMoniker,&clsid); - - if (!IsEqualCLSID(&clsid,&CLSID_ItemMoniker)) - return S_FALSE; - - res=CreateBindCtx(0,&bind); - if (FAILED(res)) - return res; - - IMoniker_GetDisplayName(iface,bind,NULL,&dispName1); - IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&dispName2); + if (!pmkOtherMoniker) return S_FALSE; + - if (lstrcmpW(dispName1,dispName2)!=0) - return S_FALSE; + /* check if both are ItemMoniker */ + if(FAILED (IMoniker_GetClassID(pmkOtherMoniker,&clsid))) return S_FALSE; + if(!IsEqualCLSID(&clsid,&CLSID_ItemMoniker)) return S_FALSE; - return S_OK; + /* check if both displaynames are the same */ + if(SUCCEEDED ((res = CreateBindCtx(0,&bind)))) { + if(SUCCEEDED (IMoniker_GetDisplayName(iface,bind,NULL,&dispName1))) { + if(SUCCEEDED (IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&dispName2))) { + if(lstrcmpW(dispName1,dispName2)==0) res = S_OK; + CoTaskMemFree(dispName2); + } + CoTaskMemFree(dispName1); + } + } + return res; } /****************************************************************************** @@ -842,8 +838,8 @@ if (*ppszDisplayName==NULL) return E_OUTOFMEMORY; - strcpyW(*ppszDisplayName,This->itemDelimiter); - strcatW(*ppszDisplayName,This->itemName); + lstrcpyW(*ppszDisplayName,This->itemDelimiter); + lstrcatW(*ppszDisplayName,This->itemName); return S_OK; } @@ -991,3 +987,5 @@ return ItemMonikerImpl_QueryInterface((IMoniker*)newItemMoniker,&riid,(void**)ppmk); } + +
Index: wine/dlls/ole32/filemoniker.c =================================================================== RCS file: /home/wine/wine/dlls/ole32/filemoniker.c,v retrieving revision 1.18 diff -d -u -r1.18 filemoniker.c --- wine/dlls/ole32/filemoniker.c 31 May 2002 23:25:50 -0000 1.18 +++ wine/dlls/ole32/filemoniker.c 14 Jul 2002 20:38:45 -0000 @@ -870,21 +870,18 @@ IMoniker_GetClassID(pmkOtherMoniker,&clsid); if (!IsEqualCLSID(&clsid,&CLSID_FileMoniker)) - return S_FALSE; - res=CreateBindCtx(0,&bind); - if (FAILED(res)) - return res; - - IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath); - - if (lstrcmpiW(filePath, - This->filePathName)!=0) + res = CreateBindCtx(0,&bind); + if (FAILED(res)) return res; - return S_FALSE; + if (SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath))) { + int result = lstrcmpiW(filePath, This->filePathName); + CoTaskMemFree(filePath); + if ( result == 0 ) return S_OK; + } + return S_FALSE; - return S_OK; }