Module: wine Branch: master Commit: 19eba06a2658d5abab32642071140414a0be18b6 URL: http://source.winehq.org/git/wine.git/?a=commit;h=19eba06a2658d5abab32642071...
Author: Michael Stefaniuc mstefani@redhat.de Date: Sat May 31 19:20:14 2014 +0200
dmusic: Don't leak memory on IReferenceClock creation failure.
Also lock/unlock the module only on creation/destruction of the object.
---
dlls/dmusic/clock.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/dlls/dmusic/clock.c b/dlls/dmusic/clock.c index 2a8cd09..46a035f 100644 --- a/dlls/dmusic/clock.c +++ b/dlls/dmusic/clock.c @@ -50,8 +50,6 @@ static ULONG WINAPI IReferenceClockImpl_AddRef(IReferenceClock *iface)
TRACE("(%p)->(): new ref = %u\n", This, ref);
- DMUSIC_LockModule(); - return ref; }
@@ -62,10 +60,10 @@ static ULONG WINAPI IReferenceClockImpl_Release(IReferenceClock *iface)
TRACE("(%p)->(): new ref = %u\n", This, ref);
- if (!ref) + if (!ref) { HeapFree(GetProcessHeap(), 0, This); - - DMUSIC_UnlockModule(); + DMUSIC_UnlockModule(); + }
return ref; } @@ -123,6 +121,7 @@ static const IReferenceClockVtbl ReferenceClock_Vtbl = { HRESULT DMUSIC_CreateReferenceClockImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNOWN unkouter) { IReferenceClockImpl* clock; + HRESULT hr;
TRACE("(%p,%p,%p)\n", riid, ret_iface, unkouter);
@@ -133,9 +132,13 @@ HRESULT DMUSIC_CreateReferenceClockImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNO }
clock->IReferenceClock_iface.lpVtbl = &ReferenceClock_Vtbl; - clock->ref = 0; /* Will be inited by QueryInterface */ + clock->ref = 1; clock->rtTime = 0; clock->pClockInfo.dwSize = sizeof (DMUS_CLOCKINFO);
- return IReferenceClockImpl_QueryInterface((IReferenceClock*)clock, riid, ret_iface); + DMUSIC_LockModule(); + hr = IReferenceClockImpl_QueryInterface(&clock->IReferenceClock_iface, riid, ret_iface); + IReferenceClockImpl_Release(&clock->IReferenceClock_iface); + + return hr; }