[OLE #76] Avoid infinite loop when doing a typelib marshalled IUnknown::QueryInterface

Mike Hearn mh at codeweavers.com
Sun Feb 20 14:19:01 CST 2005


Mike Hearn <mh at codeweavers.com>
Avoid infinite loop when doing a typelib marshalled
IUnknown::QueryInterface by only doing an extra QI if requested IID is
not equal to marshalled IID.


-------------- next part --------------
--- dlls/ole32/marshal.c  (revision 142)
+++ dlls/ole32/marshal.c  (local)
@@ -1416,11 +1416,19 @@ HRESULT WINAPI CoUnmarshalInterface(IStr
 
     if (hr == S_OK)
     {
-        hr = IUnknown_QueryInterface(object, &iid, ppv);
-        if (hr)
-            ERR("Couldn't query for interface %s, hr = 0x%08lx\n",
-                debugstr_guid(riid), hr);
-        IUnknown_Release(object);
+        if (!IsEqualIID(riid, &iid))
+        {
+            TRACE("requested interface != marshalled interface, additional QI needed\n");
+            hr = IUnknown_QueryInterface(object, &iid, ppv);
+            if (hr)
+                ERR("Couldn't query for interface %s, hr = 0x%08lx\n",
+                    debugstr_guid(riid), hr);
+            IUnknown_Release(object);
+        }
+        else
+        {
+            *ppv = object;
+        }
     }
 
     IMarshal_Release(pMarshal);


More information about the wine-patches mailing list