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:
parent
096bfbd214
commit
d67f35b9dc
@ -62,8 +62,6 @@ static ULONG WINAPI IDirectMusicInstrumentImpl_AddRef(LPDIRECTMUSICINSTRUMENT if
|
|||||||
|
|
||||||
TRACE("(%p)->(): new ref = %u\n", iface, ref);
|
TRACE("(%p)->(): new ref = %u\n", iface, ref);
|
||||||
|
|
||||||
DMUSIC_LockModule();
|
|
||||||
|
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,9 +81,8 @@ static ULONG WINAPI IDirectMusicInstrumentImpl_Release(LPDIRECTMUSICINSTRUMENT i
|
|||||||
HeapFree(GetProcessHeap(), 0, This->articulations->connections);
|
HeapFree(GetProcessHeap(), 0, This->articulations->connections);
|
||||||
HeapFree(GetProcessHeap(), 0, This->articulations);
|
HeapFree(GetProcessHeap(), 0, This->articulations);
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
}
|
|
||||||
|
|
||||||
DMUSIC_UnlockModule();
|
DMUSIC_UnlockModule();
|
||||||
|
}
|
||||||
|
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
@ -125,6 +122,7 @@ static const IDirectMusicInstrumentVtbl DirectMusicInstrument_Vtbl =
|
|||||||
/* for ClassFactory */
|
/* for ClassFactory */
|
||||||
HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
|
HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
|
||||||
IDirectMusicInstrumentImpl* dminst;
|
IDirectMusicInstrumentImpl* dminst;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
dminst = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicInstrumentImpl));
|
dminst = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicInstrumentImpl));
|
||||||
if (NULL == dminst) {
|
if (NULL == dminst) {
|
||||||
@ -132,9 +130,14 @@ HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj,
|
|||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
dminst->IDirectMusicInstrument_iface.lpVtbl = &DirectMusicInstrument_Vtbl;
|
dminst->IDirectMusicInstrument_iface.lpVtbl = &DirectMusicInstrument_Vtbl;
|
||||||
dminst->ref = 0; /* will be inited by QueryInterface */
|
dminst->ref = 1;
|
||||||
|
|
||||||
return IDirectMusicInstrument_QueryInterface(&dminst->IDirectMusicInstrument_iface, lpcGUID, ppobj);
|
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)
|
static HRESULT read_from_stream(IStream *stream, void *data, ULONG size)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user