Commit 19eba06a authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

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

Also lock/unlock the module only on creation/destruction of the object.
parent 57eb95a2
...@@ -50,8 +50,6 @@ static ULONG WINAPI IReferenceClockImpl_AddRef(IReferenceClock *iface) ...@@ -50,8 +50,6 @@ static ULONG WINAPI IReferenceClockImpl_AddRef(IReferenceClock *iface)
TRACE("(%p)->(): new ref = %u\n", This, ref); TRACE("(%p)->(): new ref = %u\n", This, ref);
DMUSIC_LockModule();
return ref; return ref;
} }
...@@ -62,10 +60,10 @@ static ULONG WINAPI IReferenceClockImpl_Release(IReferenceClock *iface) ...@@ -62,10 +60,10 @@ static ULONG WINAPI IReferenceClockImpl_Release(IReferenceClock *iface)
TRACE("(%p)->(): new ref = %u\n", This, ref); TRACE("(%p)->(): new ref = %u\n", This, ref);
if (!ref) if (!ref) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
DMUSIC_UnlockModule();
DMUSIC_UnlockModule(); }
return ref; return ref;
} }
...@@ -123,6 +121,7 @@ static const IReferenceClockVtbl ReferenceClock_Vtbl = { ...@@ -123,6 +121,7 @@ static const IReferenceClockVtbl ReferenceClock_Vtbl = {
HRESULT DMUSIC_CreateReferenceClockImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNOWN unkouter) HRESULT DMUSIC_CreateReferenceClockImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNOWN unkouter)
{ {
IReferenceClockImpl* clock; IReferenceClockImpl* clock;
HRESULT hr;
TRACE("(%p,%p,%p)\n", riid, ret_iface, unkouter); TRACE("(%p,%p,%p)\n", riid, ret_iface, unkouter);
...@@ -133,9 +132,13 @@ HRESULT DMUSIC_CreateReferenceClockImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNO ...@@ -133,9 +132,13 @@ HRESULT DMUSIC_CreateReferenceClockImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNO
} }
clock->IReferenceClock_iface.lpVtbl = &ReferenceClock_Vtbl; clock->IReferenceClock_iface.lpVtbl = &ReferenceClock_Vtbl;
clock->ref = 0; /* Will be inited by QueryInterface */ clock->ref = 1;
clock->rtTime = 0; clock->rtTime = 0;
clock->pClockInfo.dwSize = sizeof (DMUS_CLOCKINFO); 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;
} }
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