Henri Verbeet : ddraw: Move the pitch / linear size validation from ddraw_surface_init() to ddraw_surface_create( ).

Alexandre Julliard julliard at wine.codeweavers.com
Mon Sep 29 13:35:41 CDT 2014


Module: wine
Branch: master
Commit: e28800c6a41b766a61c94001c593753bcf59e519
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e28800c6a41b766a61c94001c593753bcf59e519

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Mon Sep 29 09:11:52 2014 +0200

ddraw: Move the pitch / linear size validation from ddraw_surface_init() to ddraw_surface_create().

---

 dlls/ddraw/surface.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 0214a7f..0006126 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -5943,6 +5943,15 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
                 HeapFree(GetProcessHeap(), 0, texture);
                 return DDERR_INVALIDPARAMS;
             }
+
+            if ((desc->dwFlags & DDSD_LINEARSIZE)
+                    && desc->u1.dwLinearSize < wined3d_calculate_format_pitch(ddraw->wined3d, WINED3DADAPTER_DEFAULT,
+                            wined3d_desc.format, wined3d_desc.width) * ((desc->dwHeight + 3) / 4))
+            {
+                WARN("Invalid linear size %u specified.\n", desc->u1.dwLinearSize);
+                HeapFree(GetProcessHeap(), 0, texture);
+                return DDERR_INVALIDPARAMS;
+            }
         }
         else
         {
@@ -5952,6 +5961,14 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
                 HeapFree(GetProcessHeap(), 0, texture);
                 return DDERR_INVALIDPARAMS;
             }
+
+            if (desc->u1.lPitch < wined3d_calculate_format_pitch(ddraw->wined3d, WINED3DADAPTER_DEFAULT,
+                    wined3d_desc.format, wined3d_desc.width) || desc->u1.lPitch & 3)
+            {
+                WARN("Invalid pitch %u specified.\n", desc->u1.lPitch);
+                HeapFree(GetProcessHeap(), 0, texture);
+                return DDERR_INVALIDPARAMS;
+            }
         }
     }
 
@@ -6177,13 +6194,6 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, s
     {
         if (desc->dwFlags & DDSD_LPSURFACE)
         {
-            if ((desc->dwFlags & DDSD_LINEARSIZE)
-                    && desc->u1.dwLinearSize < wined3d_surface_get_pitch(wined3d_surface) * ((desc->dwHeight + 3) / 4))
-            {
-                WARN("Invalid linear size %u specified.\n", desc->u1.dwLinearSize);
-                return DDERR_INVALIDPARAMS;
-            }
-
             if (FAILED(hr = wined3d_surface_update_desc(wined3d_surface, wined3d_desc.width,
                     wined3d_desc.height, wined3d_desc.format, WINED3D_MULTISAMPLE_NONE, 0,
                     desc->lpSurface, 0)))
@@ -6207,13 +6217,6 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, s
     {
         if (desc->dwFlags & DDSD_LPSURFACE)
         {
-            if (desc->u1.lPitch < wined3d_calculate_format_pitch(ddraw->wined3d, WINED3DADAPTER_DEFAULT,
-                    wined3d_desc.format, wined3d_desc.width) || desc->u1.lPitch & 3)
-            {
-                WARN("Invalid pitch %u specified.\n", desc->u1.lPitch);
-                return DDERR_INVALIDPARAMS;
-            }
-
             if (FAILED(hr = wined3d_surface_update_desc(wined3d_surface, wined3d_desc.width,
                     wined3d_desc.height, wined3d_desc.format, WINED3D_MULTISAMPLE_NONE, 0,
                     desc->lpSurface, desc->u1.lPitch)))




More information about the wine-cvs mailing list