Commit fa8472c3 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

ole32: Allocate memory for the generic composite moniker in CompositeMonikerImpl_Construct.

Don't leak memory in the case of newCompositeMoniker->tabLastIndex == 1, which can't happen anyway. Allow construction of a moniker with no sub-monikers.
parent 9e799f20
......@@ -1746,13 +1746,19 @@ static const IMarshalVtbl VT_MarshalImpl =
* Composite-Moniker_Construct (local function)
*******************************************************************************/
static HRESULT
CompositeMonikerImpl_Construct(CompositeMonikerImpl* This,
CompositeMonikerImpl_Construct(CompositeMonikerImpl** ppThis,
LPMONIKER pmkFirst, LPMONIKER pmkRest)
{
DWORD mkSys;
IEnumMoniker *enumMoniker;
IMoniker *tempMk;
HRESULT res;
CompositeMonikerImpl *This;
*ppThis = This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
if (!This)
return E_OUTOFMEMORY;
TRACE("(%p,%p,%p)\n",This,pmkFirst,pmkRest);
......@@ -1769,6 +1775,9 @@ CompositeMonikerImpl_Construct(CompositeMonikerImpl* This,
if (This->tabMoniker==NULL)
return E_OUTOFMEMORY;
if (!pmkFirst && !pmkRest)
return S_OK;
IMoniker_IsSystemMoniker(pmkFirst,&mkSys);
/* put the first moniker contents in the beginning of the table */
......@@ -1918,26 +1927,12 @@ CreateGenericComposite(LPMONIKER pmkFirst, LPMONIKER pmkRest,
else if (pmkFirst==NULL && pmkRest==NULL)
return S_OK;
newCompositeMoniker = HeapAlloc(GetProcessHeap(), 0,sizeof(CompositeMonikerImpl));
if (newCompositeMoniker == 0)
return STG_E_INSUFFICIENTMEMORY;
hr = CompositeMonikerImpl_Construct(newCompositeMoniker,pmkFirst,pmkRest);
if (FAILED(hr)){
hr = CompositeMonikerImpl_Construct(&newCompositeMoniker,pmkFirst,pmkRest);
HeapFree(GetProcessHeap(),0,newCompositeMoniker);
if (FAILED(hr))
return hr;
}
if (newCompositeMoniker->tabLastIndex==1)
hr = IMoniker_QueryInterface(newCompositeMoniker->tabMoniker[0],&IID_IMoniker,(void**)ppmkComposite);
else
hr = IMoniker_QueryInterface((IMoniker*)newCompositeMoniker,&IID_IMoniker,(void**)ppmkComposite);
return hr;
return IMoniker_QueryInterface((IMoniker*)newCompositeMoniker,&IID_IMoniker,(void**)ppmkComposite);
}
/******************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment