compositor: Fix a potential crash at shutdown

weston_global_destroy_save() can directly destroy a global if the
compositor state is WESTON_COMPOSITOR_OFFSCREEN.

Make sure we don't try to set_user_data after this has happened.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2025-04-02 13:00:06 -05:00 committed by Marius Vlad
parent 81800294a9
commit d9893c6af2

View file

@ -6528,11 +6528,10 @@ weston_head_remove_global(struct weston_head *head)
{
struct wl_resource *resource, *tmp;
if (head->global)
if (head->global) {
wl_global_set_user_data(head->global, NULL);
weston_global_destroy_save(head->compositor, head->global);
wl_global_set_user_data(head->global, NULL);
}
head->global = NULL;
wl_resource_for_each_safe(resource, tmp, &head->resource_list) {