Fixes for memory leaks on error path.
One fix for use of previous released pointer.
This commit is contained in:
parent
4ba3b0aa0b
commit
ab64e3f095
|
@ -1632,14 +1632,14 @@ HRESULT WINAPI EnumMonikerImpl_CreateEnumMoniker(IMoniker** tabMoniker,
|
|||
int i;
|
||||
|
||||
|
||||
if (currentPos > tabSize)
|
||||
return E_INVALIDARG;
|
||||
|
||||
newEnumMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(EnumMonikerImpl));
|
||||
|
||||
if (newEnumMoniker == 0)
|
||||
return STG_E_INSUFFICIENTMEMORY;
|
||||
|
||||
if (currentPos > tabSize)
|
||||
return E_INVALIDARG;
|
||||
|
||||
/* Initialize the virtual function table. */
|
||||
newEnumMoniker->lpVtbl = &VT_EnumMonikerImpl;
|
||||
newEnumMoniker->ref = 0;
|
||||
|
@ -1649,8 +1649,10 @@ HRESULT WINAPI EnumMonikerImpl_CreateEnumMoniker(IMoniker** tabMoniker,
|
|||
|
||||
newEnumMoniker->tabMoniker=HeapAlloc(GetProcessHeap(),0,tabSize*sizeof(IMoniker));
|
||||
|
||||
if (newEnumMoniker->tabMoniker==NULL)
|
||||
if (newEnumMoniker->tabMoniker==NULL) {
|
||||
HeapFree(GetProcessHeap(), 0, newEnumMoniker);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
if (leftToRigth)
|
||||
for (i=0;i<tabSize;i++){
|
||||
|
|
|
@ -281,6 +281,7 @@ HRESULT WINAPI FileMonikerImpl_Load(IMoniker* iface,IStream* pStm)
|
|||
/* read filePath string */
|
||||
filePathA=HeapAlloc(GetProcessHeap(),0,length);
|
||||
res=IStream_Read(pStm,filePathA,length,&bread);
|
||||
HeapFree(GetProcessHeap(),0,filePathA);
|
||||
if (bread != length)
|
||||
return E_FAIL;
|
||||
|
||||
|
@ -330,8 +331,6 @@ HRESULT WINAPI FileMonikerImpl_Load(IMoniker* iface,IStream* pStm)
|
|||
|
||||
This->filePathName=filePathW;
|
||||
|
||||
HeapFree(GetProcessHeap(),0,filePathA);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -1030,6 +1029,7 @@ HRESULT WINAPI FileMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOth
|
|||
IMoniker_IsSystemMoniker(pmkOther,&mkSys);
|
||||
|
||||
if(mkSys==MKSYS_FILEMONIKER){
|
||||
HRESULT ret;
|
||||
|
||||
CreateBindCtx(0,&pbind);
|
||||
|
||||
|
@ -1068,24 +1068,26 @@ HRESULT WINAPI FileMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOth
|
|||
sameIdx--;
|
||||
|
||||
if (machimeNameCase && (sameIdx<=3) && (nb1 > 3 || nb2 > 3) )
|
||||
return MK_E_NOPREFIX;
|
||||
|
||||
for(i=0;i<sameIdx;i++)
|
||||
strcatW(commonPath,stringTable1[i]);
|
||||
|
||||
for(i=0;i<nb1;i++)
|
||||
CoTaskMemFree(stringTable1[i]);
|
||||
|
||||
CoTaskMemFree(stringTable1);
|
||||
|
||||
for(i=0;i<nb2;i++)
|
||||
CoTaskMemFree(stringTable2[i]);
|
||||
|
||||
CoTaskMemFree(stringTable2);
|
||||
|
||||
ret = MK_E_NOPREFIX;
|
||||
else
|
||||
{
|
||||
for(i=0;i<sameIdx;i++)
|
||||
strcatW(commonPath,stringTable1[i]);
|
||||
|
||||
for(i=0;i<nb1;i++)
|
||||
CoTaskMemFree(stringTable1[i]);
|
||||
|
||||
CoTaskMemFree(stringTable1);
|
||||
|
||||
for(i=0;i<nb2;i++)
|
||||
CoTaskMemFree(stringTable2[i]);
|
||||
|
||||
CoTaskMemFree(stringTable2);
|
||||
|
||||
ret = CreateFileMoniker(commonPath,ppmkPrefix);
|
||||
}
|
||||
HeapFree(GetProcessHeap(),0,commonPath);
|
||||
|
||||
return CreateFileMoniker(commonPath,ppmkPrefix);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
return MonikerCommonPrefixWith(iface,pmkOther,ppmkPrefix);
|
||||
|
|
|
@ -376,10 +376,8 @@ HRESULT WINAPI ProgIDFromCLSID16(
|
|||
if (ret == S_OK)
|
||||
{
|
||||
ret = _xmalloc16(buf2len+1, (SEGPTR*)lplpszProgID);
|
||||
if (ret != S_OK)
|
||||
return ret;
|
||||
strcpy(MapSL((SEGPTR)*lplpszProgID),buf2);
|
||||
ret = S_OK;
|
||||
if (ret == S_OK)
|
||||
strcpy(MapSL((SEGPTR)*lplpszProgID),buf2);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, buf2);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue