1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-29 02:22:19 +00:00

x11, wayland: do not accidentally close FD 0

Both backends have code to close each FD of their wakeup_pipe array.
This array is default-initialized with 0, which means if the backends
exit before the wakeup pipe is created (e.g. when probing), they would
close FD 0.

Initialize the FDs with -1. Then we call close(-1) in these situations,
which is perfectly allowed and has no bad consequences.
This commit is contained in:
wm4 2016-07-21 15:14:37 +02:00
parent b4acfcc8aa
commit 16d276308a
2 changed files with 6 additions and 2 deletions

View File

@ -1009,8 +1009,11 @@ int vo_wayland_init(struct vo *vo)
{
vo->wayland = talloc_zero(NULL, struct vo_wayland_state);
struct vo_wayland_state *wl = vo->wayland;
wl->vo = vo;
wl->log = mp_log_new(wl, vo->log, "wayland");
*wl = (struct vo_wayland_state){
.vo = vo,
.log = mp_log_new(wl, vo->log, "wayland"),
.wakeup_pipe = {-1, -1},
};
wl_list_init(&wl->display.output_list);

View File

@ -543,6 +543,7 @@ int vo_x11_init(struct vo *vo)
.input_ctx = vo->input_ctx,
.screensaver_enabled = true,
.xrandr_event = -1,
.wakeup_pipe = {-1, -1},
};
vo->x11 = x11;