From e315068b9848d7fc920eb21340a076bb6587c1ff Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Fri, 1 Sep 2023 12:48:22 +0300 Subject: [PATCH] xdg-popup: validate parent This matches Mutter's behavior. Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3576 --- types/xdg_shell/wlr_xdg_popup.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/xdg_shell/wlr_xdg_popup.c b/types/xdg_shell/wlr_xdg_popup.c index 99f45d59..1bb73ddc 100644 --- a/types/xdg_shell/wlr_xdg_popup.c +++ b/types/xdg_shell/wlr_xdg_popup.c @@ -376,6 +376,12 @@ void create_xdg_popup(struct wlr_xdg_surface *surface, return; } + if (parent != NULL && parent->role == WLR_XDG_SURFACE_ROLE_NONE) { + wl_resource_post_error(surface->client->resource, XDG_WM_BASE_ERROR_INVALID_POPUP_PARENT, + "a popup parent must have a role"); + return; + } + assert(surface->popup == NULL); surface->popup = calloc(1, sizeof(struct wlr_xdg_popup)); if (!surface->popup) {