From c1ab3f39d73a041b488acf7296456840fa83c0da Mon Sep 17 00:00:00 2001 From: Keyu Tao Date: Mon, 6 Feb 2023 15:29:47 +0800 Subject: [PATCH] wayland/outputs: Fix potential crash when output has no monitor bind_output() creates output interface resource, but does not set implementation for it when wayland_output->monitor is NULL. However, when the wayland library is running wl_closure_invoke(), it expects the implementation to be non-NULL, and if not, it just segfaults mutter by NULL pointer dereference. This commit tries to address this issue by setting an implementation when wayland_output->monitor is NULL. This could help prevent crash when resuming from suspend or hotplugging displays. Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2570 Part-of: --- src/wayland/meta-wayland-outputs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wayland/meta-wayland-outputs.c b/src/wayland/meta-wayland-outputs.c index 1a93762d6..ed3797a03 100644 --- a/src/wayland/meta-wayland-outputs.c +++ b/src/wayland/meta-wayland-outputs.c @@ -317,7 +317,12 @@ bind_output (struct wl_client *client, monitor = wayland_output->monitor; if (!monitor) - return; + { + wl_resource_set_implementation (resource, + &meta_wl_output_interface, + NULL, NULL); + return; + } wayland_output->resources = g_list_prepend (wayland_output->resources, resource);