ddraw: fix for DDSURFACEDESC param in CreateSurface

Jesse Allen the3dfxdude at gmail.com
Tue Oct 10 10:49:09 CDT 2006


An older app may pass in DDSURFACEDESC instead of DDSURFACEDESC2. We
must be careful to not treat it the wrong way. This adds in checks to
prevent incorrect accesses when it does happen. This fixes a crashing
regression from the MIPMAPSUBLEVEL patch with apps using the older
surface struct.

Note: ddsCaps in DDSURFACEDESC represents DDSCAPS and in
DDSURFACEDESC2 represents DDSCAPS2.
-------------- next part --------------
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 341d936..8f85231 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -2136,7 +2136,8 @@ IDirectDrawImpl_CreateSurface(IDirectDra
     }
 
     /* According to the msdn this flag is ignored by CreateSurface */
-    DDSD->ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
+    if (DDSD->dwSize != sizeof(DDSURFACEDESC));
+        DDSD->ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
 
     /* Modify some flags */
     memset(&desc2, 0, sizeof(desc2));
@@ -2314,7 +2315,7 @@ IDirectDrawImpl_CreateSurface(IDirectDra
         desc2.ddsCaps.dwCaps |= DDSCAPS_BACKBUFFER;
     }
     /* Set the DDSCAPS2_MIPMAPSUBLEVEL flag on mipmap sublevels according to the msdn */
-    if(DDSD->ddsCaps.dwCaps & DDSCAPS_MIPMAP)
+    if((DDSD->ddsCaps.dwCaps & DDSCAPS_MIPMAP)&&(DDSD->dwSize != sizeof(DDSURFACEDESC)))
     {
         desc2.ddsCaps.dwCaps2 |= DDSCAPS2_MIPMAPSUBLEVEL;
     }


More information about the wine-patches mailing list