Matteo Bruni : d3d8: Validate vertex stride in Draw[Indexed]PrimitiveUP().

Alexandre Julliard julliard at winehq.org
Fri Aug 23 09:31:26 CDT 2019


Module: wine
Branch: stable
Commit: 2305f7966f9cd8578350a905f75d9b15dfaf6f4b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=2305f7966f9cd8578350a905f75d9b15dfaf6f4b

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Tue Mar 12 21:25:10 2019 +0100

d3d8: Validate vertex stride in Draw[Indexed]PrimitiveUP().

Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 59e32ecbbe7c9a7ba2dd036d242861b33c88e684)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/d3d8/device.c       |  8 ++++----
 dlls/d3d8/tests/device.c | 12 ++++++++++++
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 1d892ec..5c1be80 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -2423,9 +2423,9 @@ static HRESULT WINAPI d3d8_device_DrawPrimitiveUP(IDirect3DDevice8 *iface,
     TRACE("iface %p, primitive_type %#x, primitive_count %u, data %p, stride %u.\n",
             iface, primitive_type, primitive_count, data, stride);
 
-    if (!primitive_count)
+    if (!primitive_count || !stride)
     {
-        WARN("primitive_count is 0, returning D3D_OK\n");
+        WARN("primitive_count or stride is 0, returning D3D_OK.\n");
         return D3D_OK;
     }
 
@@ -2523,9 +2523,9 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface
             iface, primitive_type, min_vertex_idx, vertex_count, primitive_count,
             index_data, index_format, vertex_data, vertex_stride);
 
-    if (!primitive_count)
+    if (!primitive_count || !vertex_stride)
     {
-        WARN("primitive_count is 0, returning D3D_OK\n");
+        WARN("primitive_count or vertex_stride is 0, returning D3D_OK.\n");
         return D3D_OK;
     }
 
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index 0f8f15d..d0e840a 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -9282,6 +9282,11 @@ static void test_draw_primitive(void)
     ok(stride == sizeof(*quad), "Unexpected stride %u.\n", stride);
     IDirect3DVertexBuffer8_Release(current_vb);
 
+    hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, quad, 0);
+    ok(hr == D3D_OK, "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, quad, sizeof(*quad));
+    ok(hr == D3D_OK, "DrawPrimitiveUP failed, hr %#x.\n", hr);
+
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 2, quad, sizeof(*quad));
     ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
 
@@ -9308,6 +9313,13 @@ static void test_draw_primitive(void)
     ok(base_vertex_index == 1, "Unexpected base vertex index %u.\n", base_vertex_index);
     IDirect3DIndexBuffer8_Release(current_ib);
 
+    hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4, 0,
+            indices, D3DFMT_INDEX16, quad, 0);
+    ok(SUCCEEDED(hr), "DrawIndexedPrimitiveUP failed, hr %#x.\n", hr);
+    hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4, 2,
+            indices, D3DFMT_INDEX16, quad, 0);
+    ok(SUCCEEDED(hr), "DrawIndexedPrimitiveUP failed, hr %#x.\n", hr);
+
     hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4, 2,
             indices, D3DFMT_INDEX16, quad, sizeof(*quad));
     ok(SUCCEEDED(hr), "DrawIndexedPrimitiveUP failed, hr %#x.\n", hr);




More information about the wine-cvs mailing list