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@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2019-03-12 21:25:09 +01:00 committed by Alexandre Julliard
parent 7912a19ad3
commit 758cdfa02d
2 changed files with 23 additions and 1 deletions

View File

@ -2915,9 +2915,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;
}
@ -3026,6 +3031,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");

View File

@ -2981,6 +2981,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);
@ -3009,6 +3014,13 @@ static void test_draw_primitive(void)
ok(current_ib == index_buffer, "Unexpected index buffer %p.\n", current_ib);
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);