[PATCH 2/3] wined3d: Block validation checks the surface size too.

Stefan Dösinger stefandoesinger at gmx.at
Sun Jan 17 08:40:05 CST 2016


Signed-off-by: Stefan Dösinger <stefandoesinger at gmx.at>
---
 dlls/d3d9/tests/device.c | 2 +-
 dlls/wined3d/surface.c   | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 16723df..0c7afd8 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -7944,7 +7944,7 @@ static void test_surface_blocks(void)
         rect.right = formats[i].block_width;
         rect.bottom = formats[i].block_height;
         hr = IDirect3DTexture9_LockRect(texture, 1, &locked_rect, &rect, 0);
-        todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
         if (SUCCEEDED(hr))
             IDirect3DTexture9_UnlockRect(texture, 1);
 
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 829a515..db33791 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1538,6 +1538,12 @@ static BOOL surface_check_block_align(struct wined3d_surface *surface, const str
             && box->bottom == surface->resource.height)
         return TRUE;
 
+    if ((box->left >= box->right)
+            || (box->top >= box->bottom)
+            || (box->right > surface->resource.width)
+            || (box->bottom > surface->resource.height))
+        return FALSE;
+
     /* This assumes power of two block sizes, but NPOT block sizes would be
      * silly anyway. */
     width_mask = surface->resource.format->block_width - 1;
-- 
2.4.10




More information about the wine-patches mailing list