[mutter] wayland/cursor-role: Handle premature wl_buffer destruction



commit 640178a94ff354fa91f836fc945a994292acddc4
Author: Jonas Ådahl <jadahl gmail com>
Date:   Wed Sep 7 16:23:25 2016 +0800

    wayland/cursor-role: Handle premature wl_buffer destruction
    
    If a client would attach a buffer to a surface, commit, destroy the
    buffer and then later set the surface as a cursor, there will be no
    wl_buffer available to be used by the cursor role. Instead of
    dereferencing the non-existing wl_buffer resource, handle this situation
    by logging a warning and treating a prematurely destroyd wl_buffer as if
    no buffer had been attached.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770992

 src/wayland/meta-wayland-surface-role-cursor.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/wayland/meta-wayland-surface-role-cursor.c b/src/wayland/meta-wayland-surface-role-cursor.c
index dd64156..cc645fb 100644
--- a/src/wayland/meta-wayland-surface-role-cursor.c
+++ b/src/wayland/meta-wayland-surface-role-cursor.c
@@ -230,9 +230,11 @@ cursor_surface_role_constructed (GObject *object)
   MetaWaylandBuffer *buffer;
 
   buffer = meta_wayland_surface_get_buffer (surface);
-  if (buffer)
+
+  g_warn_if_fail (!buffer || buffer->resource);
+
+  if (buffer && buffer->resource)
     {
-      g_assert (buffer->resource);
       g_set_object (&priv->buffer, buffer);
       meta_wayland_surface_ref_buffer_use_count (surface);
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]