mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 07:08:04 +02:00
radv: honour the number of properties available
Cap up-to the number of properties available while copying the data.
Otherwise we might crash and/or leak data.
Cc: Dave Airlie <airlied@redhat.com>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit a025c5b2c7)
This commit is contained in:
parent
960a87fb17
commit
d653c84a68
1 changed files with 7 additions and 11 deletions
|
|
@ -659,17 +659,15 @@ VkResult radv_EnumerateInstanceExtensionProperties(
|
|||
uint32_t* pPropertyCount,
|
||||
VkExtensionProperties* pProperties)
|
||||
{
|
||||
unsigned i;
|
||||
if (pProperties == NULL) {
|
||||
*pPropertyCount = ARRAY_SIZE(global_extensions);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
for (i = 0; i < *pPropertyCount; i++)
|
||||
memcpy(&pProperties[i], &global_extensions[i], sizeof(VkExtensionProperties));
|
||||
*pPropertyCount = MIN2(*pPropertyCount, ARRAY_SIZE(global_extensions));
|
||||
typed_memcpy(pProperties, global_extensions, *pPropertyCount);
|
||||
|
||||
*pPropertyCount = i;
|
||||
if (i < ARRAY_SIZE(global_extensions))
|
||||
if (*pPropertyCount < ARRAY_SIZE(global_extensions))
|
||||
return VK_INCOMPLETE;
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
|
@ -681,19 +679,17 @@ VkResult radv_EnumerateDeviceExtensionProperties(
|
|||
uint32_t* pPropertyCount,
|
||||
VkExtensionProperties* pProperties)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
if (pProperties == NULL) {
|
||||
*pPropertyCount = ARRAY_SIZE(device_extensions);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
for (i = 0; i < *pPropertyCount; i++)
|
||||
memcpy(&pProperties[i], &device_extensions[i], sizeof(VkExtensionProperties));
|
||||
*pPropertyCount = MIN2(*pPropertyCount, ARRAY_SIZE(device_extensions));
|
||||
typed_memcpy(pProperties, device_extensions, *pPropertyCount);
|
||||
|
||||
*pPropertyCount = i;
|
||||
if (i < ARRAY_SIZE(device_extensions))
|
||||
if (*pPropertyCount < ARRAY_SIZE(device_extensions))
|
||||
return VK_INCOMPLETE;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue