From d2a858e879028db8065e8210e6c932c09a452a43 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 2 Feb 2022 16:51:45 +0000 Subject: [PATCH] gl-renderer: Prepare for buffer to outlive resource Make sure we don't die if we're asked to flush the damage on a SHM buffer which has subsequently been destroyed. Signed-off-by: Daniel Stone --- libweston/renderer-gl/gl-renderer.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index 99d80df6..aef37499 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -1849,6 +1849,12 @@ gl_renderer_flush_damage(struct weston_surface *surface, pixman_region32_union(&gs->texture_damage, &gs->texture_damage, &surface->damage); + /* This can happen if a SHM wl_buffer gets destroyed before we flush + * damage, because wayland-server just nukes the wl_shm_buffer from + * underneath us */ + if (!buffer->shm_buffer) + return; + /* Avoid upload, if the texture won't be used this time. * We still accumulate the damage in texture_damage, and * hold the reference to the buffer, in case the surface