summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2021-11-20 10:48:09 -0600
committerDudemanguy <random342@airmail.cc>2021-11-20 10:48:09 -0600
commitd2c2bf5a13bbaedd0f8c6ea8af227dffe95bdb40 (patch)
treeb768bfc74f695150ea280e90d8995c6d5e50a9c5
parent21cdc713bc5e9664ca6f02719217467fe2a9d17f (diff)
downloadmpv-d2c2bf5a13bbaedd0f8c6ea8af227dffe95bdb40.tar.bz2
mpv-d2c2bf5a13bbaedd0f8c6ea8af227dffe95bdb40.tar.xz
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.
-rw-r--r--video/out/wayland_common.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 413e26bbb5..62f471210b 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -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;