Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
gpui: Fix double-close of fd in read_fd on linux (#48850)
Albab Hasan38800907ccca
diff --git a/crates/gpui/src/platform/linux/platform.rs b/crates/gpui/src/platform/linux/platform.rsindex 5f328cd9280..4ed42608d73 100644--- a/crates/gpui/src/platform/linux/platform.rs+++ b/crates/gpui/src/platform/linux/platform.rs@@ -9,7 +9,7 @@ use std::{ffi::OsString,fs::File,io::Read as _,- os::fd::{AsFd, AsRawFd, FromRawFd},+ os::fd::{AsFd, FromRawFd, IntoRawFd},time::Duration,};@@ -737,8 +737,8 @@ pub(super) fn get_xkb_compose_state(cx: &xkb::Context) -> Option<xkb::compose::S}#[cfg(any(feature = "wayland", feature = "x11"))]-pub(super) unsafe fn read_fd(mut fd: filedescriptor::FileDescriptor) -> Result<Vec<u8>> {- let mut file = unsafe { File::from_raw_fd(fd.as_raw_fd()) };+pub(super) unsafe fn read_fd(fd: filedescriptor::FileDescriptor) -> Result<Vec<u8>> {+ let mut file = unsafe { File::from_raw_fd(fd.into_raw_fd()) };let mut buffer = Vec::new();file.read_to_end(&mut buffer)?;Ok(buffer)