Commit 758cdfa0 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

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

parent 7912a19a
......@@ -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");
......
......@@ -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);
......@@ -3010,6 +3015,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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment