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 <jeri.li@mediatek.com>
This commit is contained in:
Jeri Li 2024-09-08 16:21:49 +08:00 committed by Marius Vlad
parent 68bbc4cf51
commit 04f27f1be2
2 changed files with 16 additions and 0 deletions

View file

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

View file

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