From: Jacek Caban Subject: oleaut32: Ensure that we're using the right interface in CreateStub implementation. Message-Id: <55E9692A.3060505@codeweavers.com> Date: Fri, 4 Sep 2015 11:49:30 +0200 The patch fixes bug 39198, which is a regression from a commit that revealed a problem in oleaut32. While testing it, I found that the fix is not exactly right. I will work on a better fix, but I'm sending this now so that it has a chance to be committed before release. --- dlls/oleaut32/tmarshal.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/dlls/oleaut32/tmarshal.c b/dlls/oleaut32/tmarshal.c index a2d1ea1..6608aed 100644 --- a/dlls/oleaut32/tmarshal.c +++ b/dlls/oleaut32/tmarshal.c @@ -2282,6 +2282,7 @@ PSFacBuf_CreateStub( ITypeInfo *tinfo; TMStubImpl *stub; TYPEATTR *typeattr; + IUnknown *obj; TRACE("(%s,%p,%p)\n",debugstr_guid(riid),pUnkServer,ppStub); @@ -2291,16 +2292,26 @@ PSFacBuf_CreateStub( return hres; } + /* FIXME: This is not exactly right. We should probably call QI later. */ + hres = IUnknown_QueryInterface(pUnkServer, riid, (void**)&obj); + if (FAILED(hres)) { + WARN("Could not get %s iface: %08x\n", debugstr_guid(riid), hres); + obj = pUnkServer; + IUnknown_AddRef(obj); + } + stub = CoTaskMemAlloc(sizeof(TMStubImpl)); - if (!stub) + if (!stub) { + IUnknown_Release(obj); return E_OUTOFMEMORY; + } stub->IRpcStubBuffer_iface.lpVtbl = &tmstubvtbl; stub->ref = 1; stub->tinfo = tinfo; stub->dispatch_stub = NULL; stub->dispatch_derivative = FALSE; stub->iid = *riid; - hres = IRpcStubBuffer_Connect(&stub->IRpcStubBuffer_iface,pUnkServer); + hres = IRpcStubBuffer_Connect(&stub->IRpcStubBuffer_iface, obj); *ppStub = &stub->IRpcStubBuffer_iface; TRACE("IRpcStubBuffer: %p\n", stub); if (hres) @@ -2315,6 +2326,7 @@ PSFacBuf_CreateStub( ITypeInfo_ReleaseTypeAttr(tinfo, typeattr); } + IUnknown_Release(obj); return hres; }