atl: handle version 1 modules gracefully

Aric Stewart aric at codeweavers.com
Tue Aug 23 12:52:33 CDT 2005


version 1 atl modules only have a structure size of 100 and no functions 
to call. Handle this case so we are not corrupting memory and calling 
non-existant functions.
-------------- next part --------------
Index: dlls/atl/atl_main.c
===================================================================
RCS file: /home/wine/wine/dlls/atl/atl_main.c,v
retrieving revision 1.12
diff -u -r1.12 atl_main.c
--- dlls/atl/atl_main.c	19 Aug 2005 09:58:02 -0000	1.12
+++ dlls/atl/atl_main.c	23 Aug 2005 17:52:09 -0000
@@ -49,14 +49,24 @@
     return TRUE;
 }
 
+#define ATLVer1Size 100
+
 HRESULT WINAPI AtlModuleInit(_ATL_MODULEA* pM, _ATL_OBJMAP_ENTRYA* p, HINSTANCE h)
 {
     INT i;
+    UINT size;
 
     FIXME("SEMI-STUB (%p %p %p)\n",pM,p,h);
 
-    memset(pM,0,sizeof(_ATL_MODULEA));
-    pM->cbSize = sizeof(_ATL_MODULEA);
+    size = pM->cbSize;
+    if  (size != sizeof(_ATL_MODULEA) && size != ATLVer1Size)
+    {
+        FIXME("Unknown structure version (size %i)\n",size);
+        return E_INVALIDARG;
+    }
+    
+    memset(pM,0,pM->cbSize);
+    pM->cbSize = size;
     pM->m_hInst = h;
     pM->m_hInstResource = h;
     pM->m_hInstTypeLib = h;
@@ -65,7 +75,7 @@
 
     /* call mains */
     i = 0;
-    if (pM->m_pObjMap != NULL)
+    if (pM->m_pObjMap != NULL  && size > ATLVer1Size)
     {
         while (pM->m_pObjMap[i].pclsid != NULL)
         {


More information about the wine-patches mailing list