pixman-renderer: Check if the shm_buffer is gone during attach

Moving attach to the render loop in c08a6ff8bd
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 <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2024-06-24 13:40:22 -05:00 committed by Daniel Stone
parent 08386229ad
commit 08c7015a32
1 changed files with 5 additions and 0 deletions

View File

@ -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)) {