From 21c1d9739b8570b9c1ded2e7d00310a5a97a400d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 4 Jan 2021 18:32:22 +0100 Subject: [PATCH] =?UTF-8?q?input:=20don=E2=80=99t=20try=20to=20close=20an?= =?UTF-8?q?=20invalid=20FD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- input.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/input.c b/input.c index fe9e143a..e4a1f306 100644 --- a/input.c +++ b/input.c @@ -1596,7 +1596,7 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, xdg_toplevel_set_maximized(win->xdg_toplevel); } - else if (button == BTN_LEFT && win->csd.move_timeout_fd == -1) { + else if (button == BTN_LEFT && win->csd.move_timeout_fd < 0) { const struct itimerspec timeout = { .it_value = {.tv_nsec = 200000000}, }; @@ -1610,14 +1610,15 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, win->csd.serial = serial; } else { LOG_ERRNO("failed to configure XDG toplevel move timer FD"); - close(fd); + if (fd >= 0) + close(fd); } } } else if (state == WL_POINTER_BUTTON_STATE_RELEASED) { struct wl_window *win = term->window; - if (win->csd.move_timeout_fd != -1) { + if (win->csd.move_timeout_fd >= 0) { fdm_del(wayl->fdm, win->csd.move_timeout_fd); win->csd.move_timeout_fd = -1; }