From: Georges Basile Stavracas Neto Date: Tue, 1 Oct 2019 14:54:28 +0000 (-0300) Subject: wayland/surface: Only call destroy func when available X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~20^2~822^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=655c9dd526912cf551865664a03576abdaa9a76a;p=gtk4.git wayland/surface: Only call destroy func when available When calling gdk_wayland_surface_export_handle(), if we pass some 'user_data' but no 'destroy_func', GTK4 crashes. That's because in xdg_exported_handle() we are unconditionally calling destroy_func -- even when it's NULL. Fix that by checking if there's a destroy function before calling it. Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2179 --- diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index 0a8043b16e..aed4489c7c 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -4063,8 +4063,11 @@ xdg_exported_handle (void *data, GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface); impl->exported.callback (surface, handle, impl->exported.user_data); - g_clear_pointer (&impl->exported.user_data, - impl->exported.destroy_func); + if (impl->exported.destroy_func) + { + g_clear_pointer (&impl->exported.user_data, + impl->exported.destroy_func); + } } static const struct zxdg_exported_v1_listener xdg_exported_listener = {