winex11.drv: Try to work around an access violation in dib_convert

Louis. Lenders xerox_xerox2000 at yahoo.co.uk
Fri Mar 2 16:18:16 CST 2007


Skipped content of type multipart/alternative-------------- next part --------------
diff --git a/dlls/winex11.drv/dib.c b/dlls/winex11.drv/dib.c
diff --git a/dlls/winex11.drv/dib_convert.c b/dlls/winex11.drv/dib_convert.c
index d946918..dff48be 100644
--- a/dlls/winex11.drv/dib_convert.c
+++ b/dlls/winex11.drv/dib_convert.c
@@ -23,9 +23,12 @@ #include "config.h"
 
 #include <stdlib.h>
 
+#include "wine/debug.h"
+#include "wine/exception.h"
 #include "windef.h"
 #include "x11drv.h"
 
+WINE_DEFAULT_DEBUG_CHANNEL(dib);
 
 /***********************************************************************
  *           X11DRV_DIB_Convert_*
@@ -64,6 +67,12 @@ #include "x11drv.h"
  *   high bits, the green, and the source color in the low bits.
  */
 
+static WINE_EXCEPTION_FILTER(exception_filter)
+{
+    if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
+        ERR("exception caught with code 0x%08x = %d, app might be buggy?\n", GetExceptionCode(), GetExceptionCode());
+    return EXCEPTION_EXECUTE_HANDLER;
+}
 
 /*
  * 15 bit conversions
@@ -849,7 +858,17 @@ static void convert_888_to_0888_asis(int
         for (x=0; x < w2; x++) {
             /* Do 4 pixels at a time: 3 dwords in and 4 dwords out */
             DWORD srcval1,srcval2;
-            srcval1=srcpixel[0];
+            /* Some apps crash in following code-line, possibly they pass a bad pointer*/ 
+            __TRY
+            {
+              srcval1=srcpixel[0];
+            }
+            __EXCEPT(exception_filter)
+            {
+              return;
+            }
+            __ENDTRY;
+
             dstpixel[0]=( srcval1        & 0x00ffffff); /* h1, g1, l1 */
             srcval2=srcpixel[1];
             dstpixel[1]=( srcval1 >> 24) |              /* l2 */


More information about the wine-patches mailing list