mirror of https://github.com/mpv-player/mpv
wayland: fix a potential segfault on surface enter
This possibility actually existed for years. The wayland protocol is asynchronous and there's no restriction on when a compositor can send a surface enter event. In mpv's case, the surface enter event is used to set some vital things regarded geometry/scaling etc. However, this implictly assumes that wl->current_output is actually initialized. The vast majority of the time, vo_wayland_reconfig will happen first which is where wl->current_output is, and should, be created. There's no rule/law that the ordering of events will always occur in this order. Plasma with certain auto-profile conditions can send the surface enter event before mpv does its initial reconfig. That segfaults of course. Just add a check to make sure we have wl->current_output here and return if we don't. This assumes that the compositor will send us another surface enterance event when mpv actually does the initial surface commit and roundtrip request later. Wayland logs indicate this does happen. Fixes #9492.
This commit is contained in:
parent
21cdc713bc
commit
d2c2bf5a13
|
@ -681,6 +681,9 @@ static void surface_handle_enter(void *data, struct wl_surface *wl_surface,
|
|||
struct wl_output *output)
|
||||
{
|
||||
struct vo_wayland_state *wl = data;
|
||||
if (!wl->current_output)
|
||||
return;
|
||||
|
||||
struct mp_rect old_output_geometry = wl->current_output->geometry;
|
||||
struct mp_rect old_geometry = wl->geometry;
|
||||
wl->current_output = NULL;
|
||||
|
|
Loading…
Reference in New Issue