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>
This commit is contained in:
parent
0a27dd458b
commit
a025c5b2c7
|
@ -712,17 +712,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;
|
||||
|
@ -734,19 +732,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…
Reference in New Issue