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
This commit is contained in:
Jonas Ådahl 2019-09-13 17:30:11 +02:00
parent 03c00e4944
commit 4b1805c306

View File

@ -282,6 +282,9 @@ static const struct wl_buffer_interface dma_buf_buffer_impl =
MetaWaylandDmaBufBuffer * MetaWaylandDmaBufBuffer *
meta_wayland_dma_buf_from_buffer (MetaWaylandBuffer *buffer) meta_wayland_dma_buf_from_buffer (MetaWaylandBuffer *buffer)
{ {
if (!buffer->resource)
return NULL;
if (wl_resource_instance_of (buffer->resource, &wl_buffer_interface, if (wl_resource_instance_of (buffer->resource, &wl_buffer_interface,
&dma_buf_buffer_impl)) &dma_buf_buffer_impl))
return wl_resource_get_user_data (buffer->resource); return wl_resource_get_user_data (buffer->resource);