summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2021-11-20 10:48:09 -0600
committersfan5 <sfan5@live.de>2021-12-19 15:58:12 +0100
commitf2bc9e4dd112ac58f1178515e85fdef1cda78eff (patch)
tree82ac9e5284736d68ae05091683d4c98e228bf6e5
parentf8b85dd65d18c0c211a97fadee26fbcbc9e36e2e (diff)
downloadmpv-f2bc9e4dd112ac58f1178515e85fdef1cda78eff.tar.bz2
mpv-f2bc9e4dd112ac58f1178515e85fdef1cda78eff.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 72bacad15d..59ab7e9cde 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -685,6 +685,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;