dmusic: Don't leak memory on IReferenceClock creation failure.
Michael Stefaniuc
mstefani at redhat.de
Sat May 31 12:20:14 CDT 2014
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;
}
--
1.8.3.1
More information about the wine-patches
mailing list