vkd3d: Validate sub-resource index in d3d12_resource_Map().

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:
Józef Kucia
2018-11-13 00:23:27 +01:00
committed by Alexandre Julliard
parent dc36ab41e3
commit 91c11eed03
2 changed files with 13 additions and 0 deletions

View File

@@ -811,6 +811,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource *iface, UINT
const D3D12_RANGE *read_range, void **data)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
unsigned int sub_resource_count;
struct d3d12_device *device;
VkResult vr;
HRESULT hr;
@@ -826,6 +827,13 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource *iface, UINT
return E_INVALIDARG;
}
sub_resource_count = d3d12_resource_desc_get_sub_resource_count(&resource->desc);
if (sub_resource >= sub_resource_count)
{
WARN("Sub-resource index %u is out of range (%u sub-resources).\n", sub_resource, sub_resource_count);
return E_INVALIDARG;
}
if (d3d12_resource_is_texture(resource))
{
/* Textures seem to be mappable only on UMA adapters. */