From 2aea170962fef7f371fb2d71565b8b10c08d56c8 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Sat, 22 Aug 2020 03:37:00 +0300 Subject: [PATCH] Fix fd leak from keymap updates --- CHANGELOG.md | 1 + src/worker/handlers.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ce53cd..6544b5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fixed clipboard crashing, when seat has neither keyboard nor pointer focus - Advertise UTF8_STRING mimetype +- Fixed fd leaking from keymap updates ## 0.5.1 -- 2020-07-10 diff --git a/src/worker/handlers.rs b/src/worker/handlers.rs index 3296ac5..d372a91 100644 --- a/src/worker/handlers.rs +++ b/src/worker/handlers.rs @@ -1,6 +1,8 @@ #![macro_use] +use std::fs::File; use std::io::Result; +use std::os::unix::io::FromRawFd; use std::sync::mpsc::Sender; use sctk::reexports::client::protocol::wl_keyboard::Event as KeyboardEvent; @@ -120,6 +122,10 @@ pub fn keyboard_handler(seat: WlSeat, event: KeyboardEvent, mut dispatch_data: D KeyboardEvent::Leave { .. } => { dispatch_data.remove_seat(seat); } + KeyboardEvent::Keymap { fd, .. } => { + // Prevent fd leaking. + let _ = unsafe { File::from_raw_fd(fd) }; + } _ => {} } }