Fix for double delete in Vulkan DescSetLayout::Init

DescSetLayout::Init can crash when Immutable Samplers are provided.
When the vector containing the Binding info is resized, the pointer to
immutableSamplers is copied and then deleted in the old copy.
A copy constructor has been added to the Binding struct.

Fixed indexing in DescSetLayout::Init
This commit is contained in:
Jordan Logan
2017-05-25 13:56:41 -07:00
committed by Baldur Karlsson
parent 8154b93e2a
commit 1426d1bbd9
2 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ void DescSetLayout::Init(VulkanResourceManager *resourceMan, VulkanCreationInfo
if(pCreateInfo->pBindings[i].pImmutableSamplers)
{
bindings[b].immutableSampler = new ResourceId[bindings[i].descriptorCount];
bindings[b].immutableSampler = new ResourceId[bindings[b].descriptorCount];
for(uint32_t s = 0; s < bindings[b].descriptorCount; s++)
{
+13
View File
@@ -49,6 +49,19 @@ struct DescSetLayout
immutableSampler(NULL)
{
}
// Copy the immutable sampler
Binding(const Binding &b)
: descriptorType(b.descriptorType),
descriptorCount(b.descriptorCount),
stageFlags(b.stageFlags),
immutableSampler(NULL)
{
if(b.immutableSampler)
{
immutableSampler = new ResourceId[descriptorCount];
memcpy(immutableSampler, b.immutableSampler, sizeof(ResourceId) * descriptorCount);
}
}
~Binding() { SAFE_DELETE_ARRAY(immutableSampler); }
VkDescriptorType descriptorType;
uint32_t descriptorCount;