Skip to content

Commit 8733478

Browse files
ryanKkaiiiKkaiwz
authored andcommitted
fix: Initialize all handle which will free in destructor
Fix the random crash caused by free a non‑null garbage value. This patch is the improvement of PR:#1453 Signed-off-by: Ryan Zhang <[email protected]>
1 parent 97fcdee commit 8733478

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

samples/api/timestamp_queries/timestamp_queries.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ class TimestampQueries : public ApiVulkanSample
6464

6565
struct
6666
{
67-
VkPipeline skybox;
68-
VkPipeline reflect;
69-
VkPipeline composition;
70-
VkPipeline bloom[2];
67+
VkPipeline skybox = VK_NULL_HANDLE;
68+
VkPipeline reflect = VK_NULL_HANDLE;
69+
VkPipeline composition = VK_NULL_HANDLE;
70+
VkPipeline bloom[2] = {VK_NULL_HANDLE};
7171
} pipelines;
7272

7373
struct
7474
{
75-
VkPipelineLayout models;
76-
VkPipelineLayout composition;
77-
VkPipelineLayout bloom_filter;
75+
VkPipelineLayout models = VK_NULL_HANDLE;
76+
VkPipelineLayout composition = VK_NULL_HANDLE;
77+
VkPipelineLayout bloom_filter = VK_NULL_HANDLE;
7878
} pipeline_layouts;
7979

8080
struct
@@ -87,17 +87,17 @@ class TimestampQueries : public ApiVulkanSample
8787

8888
struct
8989
{
90-
VkDescriptorSetLayout models;
91-
VkDescriptorSetLayout composition;
92-
VkDescriptorSetLayout bloom_filter;
90+
VkDescriptorSetLayout models = VK_NULL_HANDLE;
91+
VkDescriptorSetLayout composition = VK_NULL_HANDLE;
92+
VkDescriptorSetLayout bloom_filter = VK_NULL_HANDLE;
9393
} descriptor_set_layouts;
9494

9595
// Framebuffer for offscreen rendering
9696
struct FrameBufferAttachment
9797
{
98-
VkImage image;
99-
VkDeviceMemory mem;
100-
VkImageView view;
98+
VkImage image = VK_NULL_HANDLE;
99+
VkDeviceMemory mem = VK_NULL_HANDLE;
100+
VkImageView view = VK_NULL_HANDLE;
101101
VkFormat format;
102102
void destroy(VkDevice device)
103103
{
@@ -109,20 +109,20 @@ class TimestampQueries : public ApiVulkanSample
109109
struct FrameBuffer
110110
{
111111
int32_t width, height;
112-
VkFramebuffer framebuffer;
112+
VkFramebuffer framebuffer = VK_NULL_HANDLE;
113113
FrameBufferAttachment color[2];
114114
FrameBufferAttachment depth;
115-
VkRenderPass render_pass;
116-
VkSampler sampler;
115+
VkRenderPass render_pass = VK_NULL_HANDLE;
116+
VkSampler sampler = VK_NULL_HANDLE;
117117
} offscreen;
118118

119119
struct
120120
{
121121
int32_t width, height;
122-
VkFramebuffer framebuffer;
122+
VkFramebuffer framebuffer = VK_NULL_HANDLE;
123123
FrameBufferAttachment color[1];
124-
VkRenderPass render_pass;
125-
VkSampler sampler;
124+
VkRenderPass render_pass = VK_NULL_HANDLE;
125+
VkSampler sampler = VK_NULL_HANDLE;
126126
} filter_pass;
127127

128128
std::vector<std::string> object_names;

0 commit comments

Comments
 (0)