Commit 59e32ecb authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

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

parent 758cdfa0
......@@ -2432,9 +2432,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;
}
......@@ -2532,9 +2532,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;
}
......
......@@ -9512,6 +9512,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);
......@@ -9538,6 +9543,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);
......
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