wayland/surface: NULL check surface resource in handle_output_bound()

Otherwise binding new wl_output's might try to send enter to the
destroyed resource. Fixes the following crash:

     #0 wl_resource_get_client at ../src/wayland-server.c:801
     #1 handle_output_bound at ../src/wayland/meta-wayland-surface.c:1287
     #3 signal_emit_unlocked_R.isra.0 at ../gobject/gsignal.c:3812
     #6 ffi_call_unix64 at ../src/x86/unix64.S:104
     #7 ffi_call_int at ../src/x86/ffi64.c:673
     #8 ffi_call at ../src/x86/ffi64.c:710
     #9 wl_closure_invoke at ../src/connection.c:1025
    #10 wl_client_connection_data at ../src/wayland-server.c:438
    #11 wl_event_loop_dispatch at ../src/event-loop.c:1027
    #12 wayland_event_source_dispatch at ../src/wayland/meta-wayland.c:125
    #15 g_main_context_iterate.isra.0 at ../glib/gmain.c:4276
    #17 meta_context_run_main_loop at ../src/core/meta-context.c:482

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2196527
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2992>
This commit is contained in:
Jonas Ådahl 2023-05-09 14:34:51 +02:00 committed by Marge Bot
parent 802c1baec7
commit 1a4f03bd79

View File

@ -1283,6 +1283,9 @@ handle_output_bound (MetaWaylandOutput *wayland_output,
struct wl_resource *output_resource,
MetaWaylandSurface *surface)
{
if (!surface->resource)
return;
if (wl_resource_get_client (output_resource) ==
wl_resource_get_client (surface->resource))
wl_surface_send_enter (surface->resource, output_resource);