From cf0fdb42eabf00fd450ab71c09220ee0970252fc Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 30 Mar 2025 20:55:23 +0200 Subject: [PATCH] Prevent initialize_freestanding from accidentally closing fd 0 --- redox-rt/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/redox-rt/src/lib.rs b/redox-rt/src/lib.rs index 131a21b01c..72dcf426ae 100644 --- a/redox-rt/src/lib.rs +++ b/redox-rt/src/lib.rs @@ -156,7 +156,8 @@ pub unsafe fn initialize_freestanding() { page.tcb_ptr = page; page.tcb_len = syscall::PAGE_SIZE; page.tls_end = (page as *mut Tcb).cast(); - *page.os_specific.thr_fd.get_mut() = None; + // Make sure to use ptr::write to prevent dropping the existing FdGuard + core::ptr::write(page.os_specific.thr_fd.get(), None); #[cfg(not(any(target_arch = "aarch64", target_arch = "riscv64")))] unsafe {