From bf4ea85470e91176cfbc4e94e6d7294db961d7c9 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 4 Jun 2019 12:51:36 +0100 Subject: [PATCH] Skip descriptorCount == 0 bindings when applying initial state * This could cause memory corruption if the final binding(s) were so empty as we write off the end of the array before eventually skipping. --- renderdoc/driver/vulkan/vk_initstate.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/renderdoc/driver/vulkan/vk_initstate.cpp b/renderdoc/driver/vulkan/vk_initstate.cpp index b74f49c22..8764139d9 100644 --- a/renderdoc/driver/vulkan/vk_initstate.cpp +++ b/renderdoc/driver/vulkan/vk_initstate.cpp @@ -744,6 +744,11 @@ bool WrappedVulkan::Serialise_InitialState(SerialiserType &ser, ResourceId id, for(uint32_t j = 0; j < initialContents.numDescriptors; j++) { + uint32_t descriptorCount = layout.bindings[j].descriptorCount; + + if(descriptorCount == 0) + continue; + writes[bind].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; writes[bind].pNext = NULL; @@ -756,8 +761,6 @@ bool WrappedVulkan::Serialise_InitialState(SerialiserType &ser, ResourceId id, writes[bind].descriptorCount = 0; writes[bind].descriptorType = layout.bindings[j].descriptorType; - uint32_t descriptorCount = layout.bindings[j].descriptorCount; - ResourceId *immutableSamplers = layout.bindings[j].immutableSampler; DescriptorSetSlot *src = srcData;