Fix check for invalid input in typelib2.c

Gerald Pfeifer gerald at
Sat Mar 6 15:24:52 CST 2010

FUNCDESC.memid is of type MEMBERID which is typedef-ed to DISPID which
in turn is typedef-ed to LONG.

MEMBERID_NIL is the same as DISPID_UNKNOWN is -1.

The check below tries to catch cases where FUNCDESC.memid is negative 
and different from DISPID_UNKNOWN.  Alas, it is broken and the second
half _never_ will trigger (cf. the attached test program).

My patch addresses this.


Fix check for invalid input in ICreateTypeInfo2_fnAddFuncDesc.

diff --git a/dlls/oleaut32/typelib2.c b/dlls/oleaut32/typelib2.c
index 4544317..c8a5806 100644
--- a/dlls/oleaut32/typelib2.c
+++ b/dlls/oleaut32/typelib2.c
@@ -1652,7 +1652,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddFuncDesc(
     TRACE("(%p,%d,%p)\n", iface, index, pFuncDesc);
-    if(!pFuncDesc || (pFuncDesc->memid>0x7fffffff && pFuncDesc->memid!=MEMBERID_NIL))
+    if(!pFuncDesc || (pFuncDesc->memid<0 && pFuncDesc->memid!=MEMBERID_NIL))
         return E_INVALIDARG;
     TRACE("{%d,%p,%p,%d,%d,%d,%d,%d,%d,%d,{%d},%d}\n", pFuncDesc->memid,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x.c
Type: text/x-c++src
Size: 290 bytes
URL: <>

More information about the wine-patches mailing list