Matteo Bruni : d3d9: Validate vertex stride in Draw[Indexed]PrimitiveUP().
Alexandre Julliard
julliard at winehq.org
Fri Aug 23 09:31:25 CDT 2019
Module: wine
Branch: stable
Commit: 865563e0655e80aa69cc9aa8b0df09ed626d3cda
URL: https://source.winehq.org/git/wine.git/?a=commit;h=865563e0655e80aa69cc9aa8b0df09ed626d3cda
Author: Matteo Bruni <mbruni at codeweavers.com>
Date: Tue Mar 12 21:25:09 2019 +0100
d3d9: Validate vertex stride in Draw[Indexed]PrimitiveUP().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46713
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 758cdfa02dce6d8facf9e6a0a7f09bcbb9cacb1b)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/d3d9/device.c | 12 +++++++++++-
dlls/d3d9/tests/device.c | 12 ++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 067ea2b..6185a5a 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2893,9 +2893,14 @@ static HRESULT WINAPI d3d9_device_DrawPrimitiveUP(IDirect3DDevice9Ex *iface,
TRACE("iface %p, primitive_type %#x, primitive_count %u, data %p, stride %u.\n",
iface, primitive_type, primitive_count, data, stride);
+ if (!stride)
+ {
+ WARN("stride is 0, returning D3DERR_INVALIDCALL.\n");
+ return D3DERR_INVALIDCALL;
+ }
if (!primitive_count)
{
- WARN("primitive_count is 0, returning D3D_OK\n");
+ WARN("primitive_count is 0, returning D3D_OK.\n");
return D3D_OK;
}
@@ -3004,6 +3009,11 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa
iface, primitive_type, min_vertex_idx, vertex_count, primitive_count,
index_data, index_format, vertex_data, vertex_stride);
+ if (!vertex_stride)
+ {
+ WARN("vertex_stride is 0, returning D3DERR_INVALIDCALL.\n");
+ return D3DERR_INVALIDCALL;
+ }
if (!primitive_count)
{
WARN("primitive_count is 0, returning D3D_OK.\n");
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 1cd548f..e105b25 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -2976,6 +2976,11 @@ static void test_draw_primitive(void)
hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLELIST, 0, 2);
ok(SUCCEEDED(hr), "DrawPrimitive failed, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 2, quad, 0);
+ ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, quad, 0);
+ ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+
hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 2, quad, sizeof(*quad));
ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
@@ -3005,6 +3010,13 @@ static void test_draw_primitive(void)
IDirect3DIndexBuffer9_Release(current_ib);
hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4, 2,
+ indices, D3DFMT_INDEX16, quad, 0);
+ ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4, 0,
+ indices, D3DFMT_INDEX16, quad, 0);
+ ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_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