From 640178a94ff354fa91f836fc945a994292acddc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 7 Sep 2016 16:23:25 +0800 Subject: [PATCH] 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 file 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 dd6415662..cc645fbef 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); }