Mesa (main): vulkan/wsi/wayland: always initialize format vector

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 16 08:56:10 UTC 2021


Module: Mesa
Branch: main
Commit: cb3b4609c1ac067bd066a01286fa19ce029804a0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cb3b4609c1ac067bd066a01286fa19ce029804a0

Author: Leandro Ribeiro <leandro.ribeiro at collabora.com>
Date:   Thu Aug  5 13:08:48 2021 -0300

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 <leandro.ribeiro at collabora.com>
Reviewed-by: Simon Ser <contact at emersion.fr>
Acked-by: Daniel Stone <daniels at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12117>

---

 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;



More information about the mesa-commit mailing list