From 39e057028cb7fe2ee827722a5a909cb968aad39a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Briano?= Date: Thu, 1 Jun 2023 14:18:21 -0700 Subject: [PATCH] vulkan/wsi: fix double free on error condition On error during wsi_wl_surface_create_swapchain(), wsi_wl_swapchain_chain_free() is called, followed by vk_free() of the recently freed chain. Move the vk_free() to wsi_wl_swapchain_destroy() to avoid the double free. Fixes dEQP-VK.wsi.wayland.swapchain.simulate_oom.* Reviewed-by: Lionel Landwerlin Part-of: --- src/vulkan/wsi/wsi_common_wayland.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index c6f70f458ce..9ccf26baba5 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -2168,8 +2168,6 @@ wsi_wl_swapchain_chain_free(struct wsi_wl_swapchain *chain, } wsi_swapchain_finish(&chain->base); - - vk_free(pAllocator, chain); } static VkResult @@ -2181,6 +2179,8 @@ wsi_wl_swapchain_destroy(struct wsi_swapchain *wsi_chain, wsi_wl_swapchain_images_free(chain); wsi_wl_swapchain_chain_free(chain, pAllocator); + vk_free(pAllocator, chain); + return VK_SUCCESS; }