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@collabora.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12117>
This commit is contained in:
Leandro Ribeiro 2021-08-05 13:08:48 -03:00 committed by Simon Ser
parent 151b65b211
commit cb3b4609c1

View file

@ -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;