diff --git a/src/xrt/compositor/util/comp_swapchain.c b/src/xrt/compositor/util/comp_swapchain.c index 55632eb23..38abe77bb 100644 --- a/src/xrt/compositor/util/comp_swapchain.c +++ b/src/xrt/compositor/util/comp_swapchain.c @@ -250,9 +250,8 @@ set_common_fields(struct comp_swapchain *sc, } static void -image_view_array_cleanup(struct vk_bundle *vk, size_t *array_size_ptr, VkImageView **views_ptr) +image_view_array_cleanup(struct vk_bundle *vk, size_t array_size, VkImageView **views_ptr) { - size_t array_size = *array_size_ptr; VkImageView *views = *views_ptr; if (views == NULL) { @@ -269,7 +268,6 @@ image_view_array_cleanup(struct vk_bundle *vk, size_t *array_size_ptr, VkImageVi free(views); - *array_size_ptr = 0; *views_ptr = NULL; } @@ -290,8 +288,10 @@ image_cleanup(struct vk_bundle *vk, struct comp_swapchain_image *image) vk->vkDeviceWaitIdle(vk->device); os_mutex_unlock(&vk->queue_mutex); - image_view_array_cleanup(vk, &image->array_size, &image->views.alpha); - image_view_array_cleanup(vk, &image->array_size, &image->views.no_alpha); + // The field array_size is shared, only reset once both are freed. + image_view_array_cleanup(vk, image->array_size, &image->views.alpha); + image_view_array_cleanup(vk, image->array_size, &image->views.no_alpha); + image->array_size = 0; } static void