dmusic: Don't leak memory on DirectMusicInstrument creation failure.

Also lock/unlock the module only on creation/destruction of the object.
This commit is contained in:
Michael Stefaniuc 2014-05-31 19:22:48 +02:00 committed by Alexandre Julliard
parent 096bfbd214
commit d67f35b9dc

View file

@ -62,8 +62,6 @@ static ULONG WINAPI IDirectMusicInstrumentImpl_AddRef(LPDIRECTMUSICINSTRUMENT if
TRACE("(%p)->(): new ref = %u\n", iface, ref);
DMUSIC_LockModule();
return ref;
}
@ -83,10 +81,9 @@ static ULONG WINAPI IDirectMusicInstrumentImpl_Release(LPDIRECTMUSICINSTRUMENT i
HeapFree(GetProcessHeap(), 0, This->articulations->connections);
HeapFree(GetProcessHeap(), 0, This->articulations);
HeapFree(GetProcessHeap(), 0, This);
DMUSIC_UnlockModule();
}
DMUSIC_UnlockModule();
return ref;
}
@ -125,16 +122,22 @@ static const IDirectMusicInstrumentVtbl DirectMusicInstrument_Vtbl =
/* for ClassFactory */
HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
IDirectMusicInstrumentImpl* dminst;
HRESULT hr;
dminst = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicInstrumentImpl));
if (NULL == dminst) {
*ppobj = NULL;
return E_OUTOFMEMORY;
}
dminst->IDirectMusicInstrument_iface.lpVtbl = &DirectMusicInstrument_Vtbl;
dminst->ref = 0; /* will be inited by QueryInterface */
return IDirectMusicInstrument_QueryInterface(&dminst->IDirectMusicInstrument_iface, lpcGUID, ppobj);
dminst->ref = 1;
DMUSIC_LockModule();
hr = IDirectMusicInstrument_QueryInterface(&dminst->IDirectMusicInstrument_iface, lpcGUID,
ppobj);
IDirectMusicInstrument_Release(&dminst->IDirectMusicInstrument_iface);
return hr;
}
static HRESULT read_from_stream(IStream *stream, void *data, ULONG size)