1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-01-18 20:11:03 +00:00

Fix a double-close in the no_args_doesnt_break test.

Fix the `no_args_doesnt_break` test to avoid calling `from_raw_fd` twice
on the same raw file descriptor, as that cause the file descriptor to be
closed twice, which means it could accidentally close some unrelated newly
created file descriptor.
This commit is contained in:
Dan Gohman 2023-09-21 15:53:59 -07:00 committed by Martin Nordholts
parent 5a240f36b9
commit 319c675f3e

View File

@ -308,8 +308,10 @@ fn no_args_doesnt_break() {
// this test exists.
let OpenptyResult { master, slave } = openpty(None, None).expect("Couldn't open pty.");
let mut master = unsafe { File::from_raw_fd(master) };
let stdin = unsafe { Stdio::from_raw_fd(slave) };
let stdout = unsafe { Stdio::from_raw_fd(slave) };
let stdin_file = unsafe { File::from_raw_fd(slave) };
let stdout_file = stdin_file.try_clone().unwrap();
let stdin = Stdio::from(stdin_file);
let stdout = Stdio::from(stdout_file);
let mut child = bat_raw_command()
.stdin(stdin)