From 27f80a90d922838d58552697573d307eed8e2b39 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 1 Dec 2021 15:49:24 +0000 Subject: [PATCH] c/render: Make it safe to call comp_resources_close in more cases Fixes #139 --- src/xrt/compositor/render/comp_resources.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/xrt/compositor/render/comp_resources.c b/src/xrt/compositor/render/comp_resources.c index 26ade387b..1eaf67577 100644 --- a/src/xrt/compositor/render/comp_resources.c +++ b/src/xrt/compositor/render/comp_resources.c @@ -680,7 +680,10 @@ comp_resources_init(struct comp_resources *r, void comp_resources_close(struct comp_resources *r) { - assert(r->vk != NULL); + // We were never initialised or already closed, always safe to call this function. + if (r->vk == NULL) { + return; + } struct vk_bundle *vk = r->vk; @@ -710,4 +713,7 @@ comp_resources_close(struct comp_resources *r) DF(Memory, r->distortion.device_memories[i]); } comp_buffer_close(vk, &r->compute.ubo); + + // Finally forget about the vk bundle. We do not own it! + r->vk = NULL; }