d3d11: Improve arguments validation in d3d10_device_CreateGeometryShaderWithStreamOutput().
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b82a566273
commit
2661fd4ce7
|
@ -4928,7 +4928,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutp
|
|||
UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
|
||||
{
|
||||
struct d3d_device *device = impl_from_ID3D10Device(iface);
|
||||
D3D11_SO_DECLARATION_ENTRY *so_entries;
|
||||
D3D11_SO_DECLARATION_ENTRY *so_entries = NULL;
|
||||
struct d3d_geometry_shader *object;
|
||||
unsigned int i, stride_count = 1;
|
||||
HRESULT hr;
|
||||
|
@ -4938,9 +4938,18 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutp
|
|||
iface, byte_code, byte_code_length, output_stream_decls,
|
||||
output_stream_decl_count, output_stream_stride, shader);
|
||||
|
||||
if (!(so_entries = d3d11_calloc(output_stream_decl_count, sizeof(*so_entries))))
|
||||
if (!output_stream_decl_count && output_stream_stride)
|
||||
{
|
||||
WARN("Stride must be 0 when declaration entry count is 0.\n");
|
||||
*shader = NULL;
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (output_stream_decl_count
|
||||
&& !(so_entries = d3d11_calloc(output_stream_decl_count, sizeof(*so_entries))))
|
||||
{
|
||||
ERR("Failed to allocate D3D11 SO declaration array memory.\n");
|
||||
*shader = NULL;
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
|
@ -4954,14 +4963,26 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutp
|
|||
so_entries[i].OutputSlot = output_stream_decls[i].OutputSlot;
|
||||
|
||||
if (output_stream_decls[i].OutputSlot)
|
||||
stride_count = 0;
|
||||
{
|
||||
stride_count = 0;
|
||||
if (output_stream_stride)
|
||||
{
|
||||
WARN("Stride must be 0 when multiple output slots are used.\n");
|
||||
HeapFree(GetProcessHeap(), 0, so_entries);
|
||||
*shader = NULL;
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hr = d3d_geometry_shader_create(device, byte_code, byte_code_length,
|
||||
so_entries, output_stream_decl_count, &output_stream_stride, stride_count, 0, &object);
|
||||
HeapFree(GetProcessHeap(), 0, so_entries);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
*shader = NULL;
|
||||
return hr;
|
||||
}
|
||||
|
||||
*shader = &object->ID3D10GeometryShader_iface;
|
||||
|
||||
|
|
Loading…
Reference in New Issue