From a19cd8b905e81857d0a75e0ec3d9e563be7ba56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ball=C3=B3=20Gy=C3=B6rgy?= Date: Tue, 3 Nov 2026 02:55:11 +0100 Subject: [PATCH] Fix crash when unexporting a destroyed Wayland surface The surface may already have been destroyed when a portal request completes, causing gtk_native_get_surface() to return NULL. Check the surface before attempting to unexport the Wayland handle to avoid dereferencing a NULL pointer. --- libportal/portal-gtk4.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libportal/portal-gtk4.c b/libportal/portal-gtk4.c index 30331afc..42b684cd 100644 --- a/libportal/portal-gtk4.c +++ b/libportal/portal-gtk4.c @@ -86,6 +86,8 @@ _xdp_parent_unexport_gtk (XdpParent *parent) if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (parent->object)))) { GdkSurface *surface = gtk_native_get_surface (GTK_NATIVE (parent->object)); + if (surface == NULL) + return; #if GTK_CHECK_VERSION(4, 12, 0) gdk_wayland_toplevel_drop_exported_handle (GDK_TOPLEVEL (surface), parent->exported_handle);