From 08c7015a3221e07f82acca4c0beb1355b3f73bf3 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Mon, 24 Jun 2024 13:40:22 -0500 Subject: [PATCH] pixman-renderer: Check if the shm_buffer is gone during attach Moving attach to the render loop in c08a6ff8bd6e1839a8fd7fe87602df9a1a8b62e2 caused this to crash if the shm buffer is destroyed between being committed to a surface and being rendered. Since we don't keep a reference to the buffer pool anyway, we might as well just skip the attachment here. Fixes: #922 Signed-off-by: Derek Foreman --- libweston/pixman-renderer.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libweston/pixman-renderer.c b/libweston/pixman-renderer.c index 2266db6bb..4ba336a6d 100644 --- a/libweston/pixman-renderer.c +++ b/libweston/pixman-renderer.c @@ -777,6 +777,11 @@ pixman_renderer_attach_internal(struct weston_surface *es, } shm_buffer = buffer->shm_buffer; + /* This can happen if a SHM wl_buffer gets destroyed before we attach, + * because wayland-server just nukes the wl_shm_buffer from underneath + * us. */ + if (!shm_buffer) + return; pixel_info = pixel_format_get_info_shm(wl_shm_buffer_get_format(shm_buffer)); if (!pixel_info || !pixman_format_supported_source(pixel_info->pixman_format)) {