ddraw: fix for DDSURFACEDESC param in CreateSurface (try 2)

Jesse Allen the3dfxdude at gmail.com
Tue Oct 10 11:06:28 CDT 2006


On 10/10/06, Jesse Allen <the3dfxdude at gmail.com> wrote:
> 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.
>
>
>


Do not use the original. Use this one instead.
-------------- next part --------------
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 341d936..5b72aa5 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(DDSURFACEDESC2))
+        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(DDSURFACEDESC2)))
     {
         desc2.ddsCaps.dwCaps2 |= DDSCAPS2_MIPMAPSUBLEVEL;
     }
diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c


More information about the wine-patches mailing list