From f3a42ef9ac1d08243f4ea50e3290512d1a07b283 Mon Sep 17 00:00:00 2001 From: Jonas Maier <> Date: Thu, 5 Mar 2026 17:16:24 +0100 Subject: fix unsafety in command execution --- src/run/mod.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/run') diff --git a/src/run/mod.rs b/src/run/mod.rs index e1dcacc..9e4ace8 100644 --- a/src/run/mod.rs +++ b/src/run/mod.rs @@ -31,8 +31,9 @@ pub fn run(se: &mut Session, cmd: Vec) { se.raw.disable(); - for (i, cmd) in pipes.cmds.iter().enumerate() { - let last = i == pipes.cmds.len() - 1; + let pipelen = pipes.cmds.len(); + for (i, cmd) in pipes.cmds.into_iter().enumerate() { + let last = i == pipelen - 1; let (reader, writer) = if !last { let (r, w) = io::pipe().unwrap(); @@ -87,12 +88,11 @@ pub fn run(se: &mut Session, cmd: Vec) { None => Box::new(io::stdout()), }; - // SAFETY: safe as long as we join all threads below again. - // panics were not considered so probably needs to be fixed - let args = &cmd.args; - let args: &'static Vec = unsafe { std::mem::transmute(args) }; - - let handle = std::thread::spawn(move || builtin.io(args, &mut input, &mut output)); + let handle = std::thread::spawn(move || { + let cmd = cmd; + let c = &cmd.args; + builtin.io(c, &mut input, &mut output) + }); threads.push(handle); } -- cgit v1.2.3