[d3d11] Validate subresource index in MapImage

Fixes crashes when passing an invalid subresource index.
This commit is contained in:
Philip Rebohle 2019-05-20 19:26:15 +02:00
parent 3168626f4b
commit 754cf6da30
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 14 additions and 0 deletions

View File

@ -214,6 +214,9 @@ namespace dxvk {
Logger::err("D3D11: Cannot map a device-local image");
return E_INVALIDARG;
}
if (unlikely(Subresource >= pTexture->CountSubresources()))
return E_INVALIDARG;
VkFormat packedFormat = m_parent->LookupPackedFormat(
pTexture->Desc()->Format, pTexture->GetFormatMode()).Format;

View File

@ -339,6 +339,9 @@ namespace dxvk {
return E_INVALIDARG;
}
if (unlikely(Subresource >= pResource->CountSubresources()))
return E_INVALIDARG;
pResource->SetMapType(Subresource, MapType);
VkFormat packedFormat = m_parent->LookupPackedFormat(

View File

@ -74,6 +74,14 @@ namespace dxvk {
const D3D11_COMMON_TEXTURE_DESC* Desc() const {
return &m_desc;
}
/**
* \brief Counts number of subresources
* \returns Number of subresources
*/
UINT CountSubresources() const {
return m_desc.ArraySize * m_desc.MipLevels;
}
/**
* \brief Map mode