Fix fd leak from keymap updates

This commit is contained in:
Kirill Chibisov 2020-08-22 03:37:00 +03:00 committed by Victor Berger
parent d688c33f23
commit 2aea170962
2 changed files with 7 additions and 0 deletions

View file

@ -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

View file

@ -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) };
}
_ => {}
}
}