From cb3b4609c1ac067bd066a01286fa19ce029804a0 Mon Sep 17 00:00:00 2001 From: Leandro Ribeiro Date: Thu, 5 Aug 2021 13:08:48 -0300 Subject: [PATCH] vulkan/wsi/wayland: always initialize format vector In wsi_wl_display_init(), the format vector is initialized only when the caller sets the function to query the formats/modifiers. But wsi_wl_display_finish() always release the vector, no matter if it has been initialized or not. For now it just works because the u_vector_foreach() macro works when the format vector is uninitialized, but it is a weird design to try to release something that has not been initialized. So in this patch we start to always initialize the format vector, even when not querying formats/modifiers. Signed-off-by: Leandro Ribeiro Reviewed-by: Simon Ser Acked-by: Daniel Stone Part-of: --- src/vulkan/wsi/wsi_common_wayland.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 3ab7b5f4624..ec55bdf4e18 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -444,18 +444,14 @@ wsi_wl_display_init(struct wsi_wayland *wsi_wl, VkResult result = VK_SUCCESS; memset(display, 0, sizeof(*display)); + if (!u_vector_init(&display->formats, sizeof(struct wsi_wl_format), + 8 * sizeof(struct wsi_wl_format))) + return VK_ERROR_OUT_OF_HOST_MEMORY; + display->wsi_wl = wsi_wl; display->wl_display = wl_display; display->sw = sw; - if (get_format_list) { - if (!u_vector_init(&display->formats, sizeof(struct wsi_wl_format), - 8 * sizeof(struct wsi_wl_format))) { - result = VK_ERROR_OUT_OF_HOST_MEMORY; - goto fail; - } - } - display->queue = wl_display_create_queue(wl_display); if (!display->queue) { result = VK_ERROR_OUT_OF_HOST_MEMORY;