layers: Initialize safe_struct pointers
otherwise they are not set to `nullptr` in default constructor, but still destroyed in destructor.
diff --git a/layers/generated/vk_safe_struct.cpp b/layers/generated/vk_safe_struct.cpp
index 9d68847..3638706 100644
--- a/layers/generated/vk_safe_struct.cpp
+++ b/layers/generated/vk_safe_struct.cpp
@@ -120,6 +120,7 @@
safe_VkInstanceCreateInfo::safe_VkInstanceCreateInfo(const VkInstanceCreateInfo* in_struct) :
sType(in_struct->sType),
flags(in_struct->flags),
+ pApplicationInfo(nullptr),
enabledLayerCount(in_struct->enabledLayerCount),
enabledExtensionCount(in_struct->enabledExtensionCount)
{
@@ -136,12 +137,11 @@
ppEnabledExtensionNames = tmp_ppEnabledExtensionNames;
if (in_struct->pApplicationInfo)
pApplicationInfo = new safe_VkApplicationInfo(in_struct->pApplicationInfo);
- else
- pApplicationInfo = NULL;
}
safe_VkInstanceCreateInfo::safe_VkInstanceCreateInfo() :
pNext(nullptr),
+ pApplicationInfo(nullptr),
ppEnabledLayerNames(nullptr),
ppEnabledExtensionNames(nullptr)
{}
@@ -150,6 +150,7 @@
{
sType = src.sType;
flags = src.flags;
+ pApplicationInfo = nullptr;
enabledLayerCount = src.enabledLayerCount;
enabledExtensionCount = src.enabledExtensionCount;
pNext = SafePnextCopy(src.pNext);
@@ -165,8 +166,6 @@
ppEnabledExtensionNames = tmp_ppEnabledExtensionNames;
if (src.pApplicationInfo)
pApplicationInfo = new safe_VkApplicationInfo(*src.pApplicationInfo);
- else
- pApplicationInfo = NULL;
}
safe_VkInstanceCreateInfo& safe_VkInstanceCreateInfo::operator=(const safe_VkInstanceCreateInfo& src)
@@ -192,6 +191,7 @@
sType = src.sType;
flags = src.flags;
+ pApplicationInfo = nullptr;
enabledLayerCount = src.enabledLayerCount;
enabledExtensionCount = src.enabledExtensionCount;
pNext = SafePnextCopy(src.pNext);
@@ -207,8 +207,6 @@
ppEnabledExtensionNames = tmp_ppEnabledExtensionNames;
if (src.pApplicationInfo)
pApplicationInfo = new safe_VkApplicationInfo(*src.pApplicationInfo);
- else
- pApplicationInfo = NULL;
return *this;
}
@@ -237,6 +235,7 @@
{
sType = in_struct->sType;
flags = in_struct->flags;
+ pApplicationInfo = nullptr;
enabledLayerCount = in_struct->enabledLayerCount;
enabledExtensionCount = in_struct->enabledExtensionCount;
pNext = SafePnextCopy(in_struct->pNext);
@@ -252,14 +251,13 @@
ppEnabledExtensionNames = tmp_ppEnabledExtensionNames;
if (in_struct->pApplicationInfo)
pApplicationInfo = new safe_VkApplicationInfo(in_struct->pApplicationInfo);
- else
- pApplicationInfo = NULL;
}
void safe_VkInstanceCreateInfo::initialize(const safe_VkInstanceCreateInfo* src)
{
sType = src->sType;
flags = src->flags;
+ pApplicationInfo = nullptr;
enabledLayerCount = src->enabledLayerCount;
enabledExtensionCount = src->enabledExtensionCount;
pNext = SafePnextCopy(src->pNext);
@@ -275,8 +273,6 @@
ppEnabledExtensionNames = tmp_ppEnabledExtensionNames;
if (src->pApplicationInfo)
pApplicationInfo = new safe_VkApplicationInfo(*src->pApplicationInfo);
- else
- pApplicationInfo = NULL;
}
safe_VkAllocationCallbacks::safe_VkAllocationCallbacks(const VkAllocationCallbacks* in_struct) :
@@ -2324,19 +2320,19 @@
sType(in_struct->sType),
flags(in_struct->flags),
stage(in_struct->stage),
- module(in_struct->module)
+ module(in_struct->module),
+ pSpecializationInfo(nullptr)
{
pNext = SafePnextCopy(in_struct->pNext);
pName = SafeStringCopy(in_struct->pName);
if (in_struct->pSpecializationInfo)
pSpecializationInfo = new safe_VkSpecializationInfo(in_struct->pSpecializationInfo);
- else
- pSpecializationInfo = NULL;
}
safe_VkPipelineShaderStageCreateInfo::safe_VkPipelineShaderStageCreateInfo() :
pNext(nullptr),
- pName(nullptr)
+ pName(nullptr),
+ pSpecializationInfo(nullptr)
{}
safe_VkPipelineShaderStageCreateInfo::safe_VkPipelineShaderStageCreateInfo(const safe_VkPipelineShaderStageCreateInfo& src)
@@ -2345,12 +2341,11 @@
flags = src.flags;
stage = src.stage;
module = src.module;
+ pSpecializationInfo = nullptr;
pNext = SafePnextCopy(src.pNext);
pName = SafeStringCopy(src.pName);
if (src.pSpecializationInfo)
pSpecializationInfo = new safe_VkSpecializationInfo(*src.pSpecializationInfo);
- else
- pSpecializationInfo = NULL;
}
safe_VkPipelineShaderStageCreateInfo& safe_VkPipelineShaderStageCreateInfo::operator=(const safe_VkPipelineShaderStageCreateInfo& src)
@@ -2367,12 +2362,11 @@
flags = src.flags;
stage = src.stage;
module = src.module;
+ pSpecializationInfo = nullptr;
pNext = SafePnextCopy(src.pNext);
pName = SafeStringCopy(src.pName);
if (src.pSpecializationInfo)
pSpecializationInfo = new safe_VkSpecializationInfo(*src.pSpecializationInfo);
- else
- pSpecializationInfo = NULL;
return *this;
}
@@ -2392,12 +2386,11 @@
flags = in_struct->flags;
stage = in_struct->stage;
module = in_struct->module;
+ pSpecializationInfo = nullptr;
pNext = SafePnextCopy(in_struct->pNext);
pName = SafeStringCopy(in_struct->pName);
if (in_struct->pSpecializationInfo)
pSpecializationInfo = new safe_VkSpecializationInfo(in_struct->pSpecializationInfo);
- else
- pSpecializationInfo = NULL;
}
void safe_VkPipelineShaderStageCreateInfo::initialize(const safe_VkPipelineShaderStageCreateInfo* src)
@@ -2406,12 +2399,11 @@
flags = src->flags;
stage = src->stage;
module = src->module;
+ pSpecializationInfo = nullptr;
pNext = SafePnextCopy(src->pNext);
pName = SafeStringCopy(src->pName);
if (src->pSpecializationInfo)
pSpecializationInfo = new safe_VkSpecializationInfo(*src->pSpecializationInfo);
- else
- pSpecializationInfo = NULL;
}
safe_VkPipelineVertexInputStateCreateInfo::safe_VkPipelineVertexInputStateCreateInfo(const VkPipelineVertexInputStateCreateInfo* in_struct) :
@@ -3302,6 +3294,15 @@
flags(in_struct->flags),
stageCount(in_struct->stageCount),
pStages(nullptr),
+ pVertexInputState(nullptr),
+ pInputAssemblyState(nullptr),
+ pTessellationState(nullptr),
+ pViewportState(nullptr),
+ pRasterizationState(nullptr),
+ pMultisampleState(nullptr),
+ pDepthStencilState(nullptr),
+ pColorBlendState(nullptr),
+ pDynamicState(nullptr),
layout(in_struct->layout),
renderPass(in_struct->renderPass),
subpass(in_struct->subpass),
@@ -3373,7 +3374,16 @@
safe_VkGraphicsPipelineCreateInfo::safe_VkGraphicsPipelineCreateInfo() :
pNext(nullptr),
- pStages(nullptr)
+ pStages(nullptr),
+ pVertexInputState(nullptr),
+ pInputAssemblyState(nullptr),
+ pTessellationState(nullptr),
+ pViewportState(nullptr),
+ pRasterizationState(nullptr),
+ pMultisampleState(nullptr),
+ pDepthStencilState(nullptr),
+ pColorBlendState(nullptr),
+ pDynamicState(nullptr)
{}
safe_VkGraphicsPipelineCreateInfo::safe_VkGraphicsPipelineCreateInfo(const safe_VkGraphicsPipelineCreateInfo& src)
@@ -3382,6 +3392,15 @@
flags = src.flags;
stageCount = src.stageCount;
pStages = nullptr;
+ pVertexInputState = nullptr;
+ pInputAssemblyState = nullptr;
+ pTessellationState = nullptr;
+ pViewportState = nullptr;
+ pRasterizationState = nullptr;
+ pMultisampleState = nullptr;
+ pDepthStencilState = nullptr;
+ pColorBlendState = nullptr;
+ pDynamicState = nullptr;
layout = src.layout;
renderPass = src.renderPass;
subpass = src.subpass;
@@ -3469,6 +3488,15 @@
flags = src.flags;
stageCount = src.stageCount;
pStages = nullptr;
+ pVertexInputState = nullptr;
+ pInputAssemblyState = nullptr;
+ pTessellationState = nullptr;
+ pViewportState = nullptr;
+ pRasterizationState = nullptr;
+ pMultisampleState = nullptr;
+ pDepthStencilState = nullptr;
+ pColorBlendState = nullptr;
+ pDynamicState = nullptr;
layout = src.layout;
renderPass = src.renderPass;
subpass = src.subpass;
@@ -3559,6 +3587,15 @@
flags = in_struct->flags;
stageCount = in_struct->stageCount;
pStages = nullptr;
+ pVertexInputState = nullptr;
+ pInputAssemblyState = nullptr;
+ pTessellationState = nullptr;
+ pViewportState = nullptr;
+ pRasterizationState = nullptr;
+ pMultisampleState = nullptr;
+ pDepthStencilState = nullptr;
+ pColorBlendState = nullptr;
+ pDynamicState = nullptr;
layout = in_struct->layout;
renderPass = in_struct->renderPass;
subpass = in_struct->subpass;
@@ -3633,6 +3670,15 @@
flags = src->flags;
stageCount = src->stageCount;
pStages = nullptr;
+ pVertexInputState = nullptr;
+ pInputAssemblyState = nullptr;
+ pTessellationState = nullptr;
+ pViewportState = nullptr;
+ pRasterizationState = nullptr;
+ pMultisampleState = nullptr;
+ pDepthStencilState = nullptr;
+ pColorBlendState = nullptr;
+ pDynamicState = nullptr;
layout = src->layout;
renderPass = src->renderPass;
subpass = src->subpass;
@@ -5451,28 +5497,27 @@
safe_VkCommandBufferBeginInfo::safe_VkCommandBufferBeginInfo(const VkCommandBufferBeginInfo* in_struct) :
sType(in_struct->sType),
- flags(in_struct->flags)
+ flags(in_struct->flags),
+ pInheritanceInfo(nullptr)
{
pNext = SafePnextCopy(in_struct->pNext);
if (in_struct->pInheritanceInfo)
pInheritanceInfo = new safe_VkCommandBufferInheritanceInfo(in_struct->pInheritanceInfo);
- else
- pInheritanceInfo = NULL;
}
safe_VkCommandBufferBeginInfo::safe_VkCommandBufferBeginInfo() :
- pNext(nullptr)
+ pNext(nullptr),
+ pInheritanceInfo(nullptr)
{}
safe_VkCommandBufferBeginInfo::safe_VkCommandBufferBeginInfo(const safe_VkCommandBufferBeginInfo& src)
{
sType = src.sType;
flags = src.flags;
+ pInheritanceInfo = nullptr;
pNext = SafePnextCopy(src.pNext);
if (src.pInheritanceInfo)
pInheritanceInfo = new safe_VkCommandBufferInheritanceInfo(*src.pInheritanceInfo);
- else
- pInheritanceInfo = NULL;
}
safe_VkCommandBufferBeginInfo& safe_VkCommandBufferBeginInfo::operator=(const safe_VkCommandBufferBeginInfo& src)
@@ -5486,11 +5531,10 @@
sType = src.sType;
flags = src.flags;
+ pInheritanceInfo = nullptr;
pNext = SafePnextCopy(src.pNext);
if (src.pInheritanceInfo)
pInheritanceInfo = new safe_VkCommandBufferInheritanceInfo(*src.pInheritanceInfo);
- else
- pInheritanceInfo = NULL;
return *this;
}
@@ -5507,22 +5551,20 @@
{
sType = in_struct->sType;
flags = in_struct->flags;
+ pInheritanceInfo = nullptr;
pNext = SafePnextCopy(in_struct->pNext);
if (in_struct->pInheritanceInfo)
pInheritanceInfo = new safe_VkCommandBufferInheritanceInfo(in_struct->pInheritanceInfo);
- else
- pInheritanceInfo = NULL;
}
void safe_VkCommandBufferBeginInfo::initialize(const safe_VkCommandBufferBeginInfo* src)
{
sType = src->sType;
flags = src->flags;
+ pInheritanceInfo = nullptr;
pNext = SafePnextCopy(src->pNext);
if (src->pInheritanceInfo)
pInheritanceInfo = new safe_VkCommandBufferInheritanceInfo(*src->pInheritanceInfo);
- else
- pInheritanceInfo = NULL;
}
safe_VkMemoryBarrier::safe_VkMemoryBarrier(const VkMemoryBarrier* in_struct) :
@@ -12879,6 +12921,7 @@
colorAttachmentCount(in_struct->colorAttachmentCount),
pColorAttachments(nullptr),
pResolveAttachments(nullptr),
+ pDepthStencilAttachment(nullptr),
preserveAttachmentCount(in_struct->preserveAttachmentCount),
pPreserveAttachments(nullptr)
{
@@ -12903,8 +12946,6 @@
}
if (in_struct->pDepthStencilAttachment)
pDepthStencilAttachment = new safe_VkAttachmentReference2KHR(in_struct->pDepthStencilAttachment);
- else
- pDepthStencilAttachment = NULL;
if (in_struct->pPreserveAttachments) {
pPreserveAttachments = new uint32_t[in_struct->preserveAttachmentCount];
memcpy ((void *)pPreserveAttachments, (void *)in_struct->pPreserveAttachments, sizeof(uint32_t)*in_struct->preserveAttachmentCount);
@@ -12916,6 +12957,7 @@
pInputAttachments(nullptr),
pColorAttachments(nullptr),
pResolveAttachments(nullptr),
+ pDepthStencilAttachment(nullptr),
pPreserveAttachments(nullptr)
{}
@@ -12930,6 +12972,7 @@
colorAttachmentCount = src.colorAttachmentCount;
pColorAttachments = nullptr;
pResolveAttachments = nullptr;
+ pDepthStencilAttachment = nullptr;
preserveAttachmentCount = src.preserveAttachmentCount;
pPreserveAttachments = nullptr;
pNext = SafePnextCopy(src.pNext);
@@ -12953,8 +12996,6 @@
}
if (src.pDepthStencilAttachment)
pDepthStencilAttachment = new safe_VkAttachmentReference2KHR(*src.pDepthStencilAttachment);
- else
- pDepthStencilAttachment = NULL;
if (src.pPreserveAttachments) {
pPreserveAttachments = new uint32_t[src.preserveAttachmentCount];
memcpy ((void *)pPreserveAttachments, (void *)src.pPreserveAttachments, sizeof(uint32_t)*src.preserveAttachmentCount);
@@ -12987,6 +13028,7 @@
colorAttachmentCount = src.colorAttachmentCount;
pColorAttachments = nullptr;
pResolveAttachments = nullptr;
+ pDepthStencilAttachment = nullptr;
preserveAttachmentCount = src.preserveAttachmentCount;
pPreserveAttachments = nullptr;
pNext = SafePnextCopy(src.pNext);
@@ -13010,8 +13052,6 @@
}
if (src.pDepthStencilAttachment)
pDepthStencilAttachment = new safe_VkAttachmentReference2KHR(*src.pDepthStencilAttachment);
- else
- pDepthStencilAttachment = NULL;
if (src.pPreserveAttachments) {
pPreserveAttachments = new uint32_t[src.preserveAttachmentCount];
memcpy ((void *)pPreserveAttachments, (void *)src.pPreserveAttachments, sizeof(uint32_t)*src.preserveAttachmentCount);
@@ -13047,6 +13087,7 @@
colorAttachmentCount = in_struct->colorAttachmentCount;
pColorAttachments = nullptr;
pResolveAttachments = nullptr;
+ pDepthStencilAttachment = nullptr;
preserveAttachmentCount = in_struct->preserveAttachmentCount;
pPreserveAttachments = nullptr;
pNext = SafePnextCopy(in_struct->pNext);
@@ -13070,8 +13111,6 @@
}
if (in_struct->pDepthStencilAttachment)
pDepthStencilAttachment = new safe_VkAttachmentReference2KHR(in_struct->pDepthStencilAttachment);
- else
- pDepthStencilAttachment = NULL;
if (in_struct->pPreserveAttachments) {
pPreserveAttachments = new uint32_t[in_struct->preserveAttachmentCount];
memcpy ((void *)pPreserveAttachments, (void *)in_struct->pPreserveAttachments, sizeof(uint32_t)*in_struct->preserveAttachmentCount);
@@ -13089,6 +13128,7 @@
colorAttachmentCount = src->colorAttachmentCount;
pColorAttachments = nullptr;
pResolveAttachments = nullptr;
+ pDepthStencilAttachment = nullptr;
preserveAttachmentCount = src->preserveAttachmentCount;
pPreserveAttachments = nullptr;
pNext = SafePnextCopy(src->pNext);
@@ -13112,8 +13152,6 @@
}
if (src->pDepthStencilAttachment)
pDepthStencilAttachment = new safe_VkAttachmentReference2KHR(*src->pDepthStencilAttachment);
- else
- pDepthStencilAttachment = NULL;
if (src->pPreserveAttachments) {
pPreserveAttachments = new uint32_t[src->preserveAttachmentCount];
memcpy ((void *)pPreserveAttachments, (void *)src->pPreserveAttachments, sizeof(uint32_t)*src->preserveAttachmentCount);
@@ -14771,17 +14809,17 @@
safe_VkSubpassDescriptionDepthStencilResolveKHR::safe_VkSubpassDescriptionDepthStencilResolveKHR(const VkSubpassDescriptionDepthStencilResolveKHR* in_struct) :
sType(in_struct->sType),
depthResolveMode(in_struct->depthResolveMode),
- stencilResolveMode(in_struct->stencilResolveMode)
+ stencilResolveMode(in_struct->stencilResolveMode),
+ pDepthStencilResolveAttachment(nullptr)
{
pNext = SafePnextCopy(in_struct->pNext);
if (in_struct->pDepthStencilResolveAttachment)
pDepthStencilResolveAttachment = new safe_VkAttachmentReference2KHR(in_struct->pDepthStencilResolveAttachment);
- else
- pDepthStencilResolveAttachment = NULL;
}
safe_VkSubpassDescriptionDepthStencilResolveKHR::safe_VkSubpassDescriptionDepthStencilResolveKHR() :
- pNext(nullptr)
+ pNext(nullptr),
+ pDepthStencilResolveAttachment(nullptr)
{}
safe_VkSubpassDescriptionDepthStencilResolveKHR::safe_VkSubpassDescriptionDepthStencilResolveKHR(const safe_VkSubpassDescriptionDepthStencilResolveKHR& src)
@@ -14789,11 +14827,10 @@
sType = src.sType;
depthResolveMode = src.depthResolveMode;
stencilResolveMode = src.stencilResolveMode;
+ pDepthStencilResolveAttachment = nullptr;
pNext = SafePnextCopy(src.pNext);
if (src.pDepthStencilResolveAttachment)
pDepthStencilResolveAttachment = new safe_VkAttachmentReference2KHR(*src.pDepthStencilResolveAttachment);
- else
- pDepthStencilResolveAttachment = NULL;
}
safe_VkSubpassDescriptionDepthStencilResolveKHR& safe_VkSubpassDescriptionDepthStencilResolveKHR::operator=(const safe_VkSubpassDescriptionDepthStencilResolveKHR& src)
@@ -14808,11 +14845,10 @@
sType = src.sType;
depthResolveMode = src.depthResolveMode;
stencilResolveMode = src.stencilResolveMode;
+ pDepthStencilResolveAttachment = nullptr;
pNext = SafePnextCopy(src.pNext);
if (src.pDepthStencilResolveAttachment)
pDepthStencilResolveAttachment = new safe_VkAttachmentReference2KHR(*src.pDepthStencilResolveAttachment);
- else
- pDepthStencilResolveAttachment = NULL;
return *this;
}
@@ -14830,11 +14866,10 @@
sType = in_struct->sType;
depthResolveMode = in_struct->depthResolveMode;
stencilResolveMode = in_struct->stencilResolveMode;
+ pDepthStencilResolveAttachment = nullptr;
pNext = SafePnextCopy(in_struct->pNext);
if (in_struct->pDepthStencilResolveAttachment)
pDepthStencilResolveAttachment = new safe_VkAttachmentReference2KHR(in_struct->pDepthStencilResolveAttachment);
- else
- pDepthStencilResolveAttachment = NULL;
}
void safe_VkSubpassDescriptionDepthStencilResolveKHR::initialize(const safe_VkSubpassDescriptionDepthStencilResolveKHR* src)
@@ -14842,11 +14877,10 @@
sType = src->sType;
depthResolveMode = src->depthResolveMode;
stencilResolveMode = src->stencilResolveMode;
+ pDepthStencilResolveAttachment = nullptr;
pNext = SafePnextCopy(src->pNext);
if (src->pDepthStencilResolveAttachment)
pDepthStencilResolveAttachment = new safe_VkAttachmentReference2KHR(*src->pDepthStencilResolveAttachment);
- else
- pDepthStencilResolveAttachment = NULL;
}
safe_VkPhysicalDeviceDepthStencilResolvePropertiesKHR::safe_VkPhysicalDeviceDepthStencilResolvePropertiesKHR(const VkPhysicalDeviceDepthStencilResolvePropertiesKHR* in_struct) :
diff --git a/scripts/helper_file_generator.py b/scripts/helper_file_generator.py
index 5b5b4bf..e78d1b9 100644
--- a/scripts/helper_file_generator.py
+++ b/scripts/helper_file_generator.py
@@ -1312,10 +1312,11 @@
construct_txt += ' }\n'
construct_txt += ' }\n'
elif member.ispointer == True:
+ default_init_list += '\n %s(nullptr),' % (member.name)
+ init_list += '\n %s(nullptr),' % (member.name)
+ init_func_txt += ' %s = nullptr;\n' % (member.name)
construct_txt += ' if (in_struct->%s)\n' % member.name
construct_txt += ' %s = new %s(in_struct->%s);\n' % (member.name, m_type, member.name)
- construct_txt += ' else\n'
- construct_txt += ' %s = NULL;\n' % member.name
destruct_txt += ' if (%s)\n' % member.name
destruct_txt += ' delete %s;\n' % member.name
elif 'safe_' in m_type: