From c520557fa571cddbdde211eaeb0981ca042765e7 Mon Sep 17 00:00:00 2001 From: Jeri Li Date: Sun, 8 Sep 2024 16:21:49 +0800 Subject: [PATCH] libweston/desktop: avoid weston crash while xdg_surface ack_configure checks the resource and sends a protocol error if the client tries to send a request to an inert object then returns out of the request handler Signed-off-by: Jeri Li (cherry picked from commit 04f27f1be2e0dd4526d994c27f6117634a51cc1d) --- libweston/desktop/xdg-shell-v6.c | 8 ++++++++ libweston/desktop/xdg-shell.c | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/libweston/desktop/xdg-shell-v6.c b/libweston/desktop/xdg-shell-v6.c index e46cdd6c5..08aef859e 100644 --- a/libweston/desktop/xdg-shell-v6.c +++ b/libweston/desktop/xdg-shell-v6.c @@ -1200,6 +1200,14 @@ weston_desktop_xdg_surface_protocol_ack_configure(struct wl_client *wl_client, { struct weston_desktop_surface *dsurface = wl_resource_get_user_data(resource); + if (dsurface == NULL) { + wl_resource_post_error(resource, + ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED, + "xdg surface already destroyed configure " + "serial: %u", serial); + return; + } + struct weston_desktop_xdg_surface *surface = weston_desktop_surface_get_implementation_data(dsurface); struct weston_desktop_xdg_surface_configure *configure, *temp; diff --git a/libweston/desktop/xdg-shell.c b/libweston/desktop/xdg-shell.c index 0ec57c7fe..4be965c81 100644 --- a/libweston/desktop/xdg-shell.c +++ b/libweston/desktop/xdg-shell.c @@ -1414,6 +1414,14 @@ weston_desktop_xdg_surface_protocol_ack_configure(struct wl_client *wl_client, { struct weston_desktop_surface *dsurface = wl_resource_get_user_data(resource); + if (dsurface == NULL) { + wl_resource_post_error(resource, + XDG_SURFACE_ERROR_DEFUNCT_ROLE_OBJECT, + "xdg surface already destroyed configure " + "serial: %u", serial); + return; + } + struct weston_desktop_xdg_surface *surface = weston_desktop_surface_get_implementation_data(dsurface); struct weston_desktop_xdg_surface_configure *configure, *temp;