Fix deallocation of uninitialized pointer
When pCreateInfo->setLayoutCount is 0, descriptorSets[0].bindings would
not be assigned the initial bindingStorage value, which is the start of
the additional memory that is allocated for the PipelineLayout object.
It is used in PipelineLayout::destroy() for deallocating said memory,
which leads to attempting to free an initialized pointer.
This was a regression caused by https://swiftshader-review.googlesource.com/c/SwiftShader/+/44328
Bug: b/154522740
Change-Id: I98f63d58e9d64b36f15d966afd1bc70c1ec97f59
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/45448
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Trevor Black <vantablack@google.com>
diff --git a/src/Vulkan/VkPipelineLayout.cpp b/src/Vulkan/VkPipelineLayout.cpp
index 9f0c12f..f01ed90 100644
--- a/src/Vulkan/VkPipelineLayout.cpp
+++ b/src/Vulkan/VkPipelineLayout.cpp
@@ -28,6 +28,9 @@
{
Binding *bindingStorage = reinterpret_cast<Binding *>(mem);
uint32_t dynamicOffsetIndex = 0;
+
+ descriptorSets[0].bindings = bindingStorage; // Used in destroy() for deallocation.
+
for(uint32_t i = 0; i < pCreateInfo->setLayoutCount; i++)
{
const vk::DescriptorSetLayout *setLayout = vk::Cast(pCreateInfo->pSetLayouts[i]);