mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 06:30:10 +01:00
radv: fix null memcpy and zero-sized malloc
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6206>
This commit is contained in:
parent
b50ae77014
commit
b553c7dd96
1 changed files with 5 additions and 4 deletions
|
|
@ -57,13 +57,14 @@ static int binding_compare(const void* av, const void *bv)
|
|||
|
||||
static VkDescriptorSetLayoutBinding *
|
||||
create_sorted_bindings(const VkDescriptorSetLayoutBinding *bindings, unsigned count) {
|
||||
VkDescriptorSetLayoutBinding *sorted_bindings = malloc(count * sizeof(VkDescriptorSetLayoutBinding));
|
||||
VkDescriptorSetLayoutBinding *sorted_bindings = malloc(MAX2(count * sizeof(VkDescriptorSetLayoutBinding), 1));
|
||||
if (!sorted_bindings)
|
||||
return NULL;
|
||||
|
||||
memcpy(sorted_bindings, bindings, count * sizeof(VkDescriptorSetLayoutBinding));
|
||||
|
||||
qsort(sorted_bindings, count, sizeof(VkDescriptorSetLayoutBinding), binding_compare);
|
||||
if (count) {
|
||||
memcpy(sorted_bindings, bindings, count * sizeof(VkDescriptorSetLayoutBinding));
|
||||
qsort(sorted_bindings, count, sizeof(VkDescriptorSetLayoutBinding), binding_compare);
|
||||
}
|
||||
|
||||
return sorted_bindings;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue