winex11.drv: Try to work around an access violation (try 2)

Louis. Lenders xerox_xerox2000 at yahoo.co.uk
Mon Mar 12 15:23:40 CDT 2007


Skipped content of type multipart/alternative-------------- next part --------------
diff --git a/dlls/winex11.drv/dib.c b/dlls/winex11.drv/dib.c
index 82cacab..08a3927 100644
--- a/dlls/winex11.drv/dib.c
+++ b/dlls/winex11.drv/dib.c
@@ -39,10 +39,19 @@
 #include "wingdi.h"
 #include "x11drv.h"
 #include "excpt.h"
+#include "wine/exception.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(bitmap);
 
+static WINE_EXCEPTION_FILTER(exceptionfilter)
+{
+    if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
+        ERR("exception caught with code 0x%08x = %d, app might be buggy?\n", GetExceptionCode(), GetExceptionCode());
+    return EXCEPTION_EXECUTE_HANDLER;
+}
+
+
 static struct list dibs_list = LIST_INIT(dibs_list);
 
 static CRITICAL_SECTION dibs_cs;
@@ -3928,7 +3937,16 @@ INT X11DRV_SetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan,
   descr.useShm    = FALSE;
   descr.dibpitch  = ((descr.infoWidth * descr.infoBpp + 31) &~31) / 8;
   X11DRV_DIB_Lock( physBitmap, DIB_Status_GdiMod, FALSE );
-  result = X11DRV_DIB_SetImageBits( &descr );
+  /* some applications pass bad pointers, try to work around this */
+  __TRY
+  {
+    result = X11DRV_DIB_SetImageBits( &descr );
+  }
+  __EXCEPT(exceptionfilter)
+  {
+    result = 0;
+  }  __ENDTRY
+
   X11DRV_DIB_Unlock( physBitmap, TRUE );
 
   HeapFree(GetProcessHeap(), 0, descr.colorMap);


More information about the wine-patches mailing list