From d3c550d0ba36e8ed7c2c9c8741d59b7df01b96c2 Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Sun, 5 Jan 2014 23:38:33 +0100 Subject: [PATCH] dmusic: Always AddRef the returned iface in QueryInterface. --- dlls/dmusic/collection.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/dlls/dmusic/collection.c b/dlls/dmusic/collection.c index f98bc196eff..a673390dba4 100644 --- a/dlls/dmusic/collection.c +++ b/dlls/dmusic/collection.c @@ -48,31 +48,22 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_QueryInt TRACE("(%p/%p)->(%s, %p)\n", iface, This, debugstr_dmguid(riid), ret_iface); - if (IsEqualIID(riid, &IID_IUnknown) || - IsEqualIID(riid, &IID_IDirectMusicCollection)) - { - *ret_iface = iface; - IDirectMusicCollection_AddRef(iface); - return S_OK; - } - else if (IsEqualIID(riid, &IID_IDirectMusicObject)) - { - *ret_iface = &This->IDirectMusicObject_iface; - IDirectMusicCollection_AddRef(iface); - return S_OK; - } - else if (IsEqualIID(riid, &IID_IPersistStream)) - { - *ret_iface = &This->IPersistStream_iface; - IDirectMusicCollection_AddRef(iface); - return S_OK; - } - *ret_iface = NULL; - WARN("(%p/%p)->(%s, %p): not found\n", iface, This, debugstr_dmguid(riid), ret_iface); + if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicCollection)) + *ret_iface = iface; + else if (IsEqualIID(riid, &IID_IDirectMusicObject)) + *ret_iface = &This->IDirectMusicObject_iface; + else if (IsEqualIID(riid, &IID_IPersistStream)) + *ret_iface = &This->IPersistStream_iface; + else + { + WARN("(%p/%p)->(%s, %p): not found\n", iface, This, debugstr_dmguid(riid), ret_iface); + return E_NOINTERFACE; + } - return E_NOINTERFACE; + IUnknown_AddRef((IUnknown*)*ret_iface); + return S_OK; } static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_AddRef(LPDIRECTMUSICCOLLECTION iface)