From 4b1805c3065eea293aefb1e3d1dc0ba685bcc1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 13 Sep 2019 17:30:11 +0200 Subject: [PATCH] wayland/dma-buf: Handle getting dma-buf from detached buffer handle We might still have a MetaWaylandBuffer for a wl_buffer that was destroyed. Handle trying to fetch the MetaWaylandDmaBufBuffer from such a buffer gracefully. https://gitlab.gnome.org/GNOME/mutter/merge_requests/798 --- src/wayland/meta-wayland-dma-buf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wayland/meta-wayland-dma-buf.c b/src/wayland/meta-wayland-dma-buf.c index 0ac231a30..e50389aec 100644 --- a/src/wayland/meta-wayland-dma-buf.c +++ b/src/wayland/meta-wayland-dma-buf.c @@ -282,6 +282,9 @@ static const struct wl_buffer_interface dma_buf_buffer_impl = MetaWaylandDmaBufBuffer * meta_wayland_dma_buf_from_buffer (MetaWaylandBuffer *buffer) { + if (!buffer->resource) + return NULL; + if (wl_resource_instance_of (buffer->resource, &wl_buffer_interface, &dma_buf_buffer_impl)) return wl_resource_get_user_data (buffer->resource);