Commit d67f35b9 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

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

Also lock/unlock the module only on creation/destruction of the object.
parent 096bfbd2
......@@ -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)
......
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