From cd4e6a14517c71285acc976fe10b12e490d72a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Yhuel?= Date: Tue, 16 Sep 2025 13:15:34 +0200 Subject: [PATCH] client: fix crash when creating proxies with no queue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before, it worked if the client did set a queue on the proxy before any event was received. Now we have the "warning: queue xxx destroyed while proxies still attached", then a crash if one of the proxies is used to create a proxy. Fixes: 674145dc3f ("client: Track the proxies attached to a queue") Fixes: 0ba650202e ("client: Warn when a queue is destroyed with attached proxies") Signed-off-by: Loïc Yhuel --- src/wayland-client.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/wayland-client.c b/src/wayland-client.c index ed686b5c..50b3b4b2 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -499,7 +499,10 @@ proxy_create(struct wl_proxy *factory, const struct wl_interface *interface, return NULL; } - wl_list_insert(&proxy->queue->proxy_list, &proxy->queue_link); + if (proxy->queue != NULL) + wl_list_insert(&proxy->queue->proxy_list, &proxy->queue_link); + else + wl_list_init(&proxy->queue_link); return proxy; } @@ -560,7 +563,10 @@ wl_proxy_create_for_id(struct wl_proxy *factory, return NULL; } - wl_list_insert(&proxy->queue->proxy_list, &proxy->queue_link); + if (proxy->queue != NULL) + wl_list_insert(&proxy->queue->proxy_list, &proxy->queue_link); + else + wl_list_init(&proxy->queue_link); return proxy; } @@ -2801,7 +2807,10 @@ wl_proxy_create_wrapper(void *proxy) wrapper->flags = WL_PROXY_FLAG_WRAPPER; wrapper->refcount = 1; - wl_list_insert(&wrapper->queue->proxy_list, &wrapper->queue_link); + if (wrapper->queue != NULL) + wl_list_insert(&wrapper->queue->proxy_list, &wrapper->queue_link); + else + wl_list_init(&wrapper->queue_link); pthread_mutex_unlock(&wrapped_proxy->display->mutex);