diff options
| author | Jonas Maier <> | 2026-03-05 17:16:24 +0100 |
|---|---|---|
| committer | Jonas Maier <> | 2026-03-05 17:16:24 +0100 |
| commit | f3a42ef9ac1d08243f4ea50e3290512d1a07b283 (patch) | |
| tree | d5aec9b3f4e486a6be5807f50de31a62f73655ab /src/run | |
| parent | 2172f24d3f714ea19a01e81a9ce454372a0b71a6 (diff) | |
| download | pish-f3a42ef9ac1d08243f4ea50e3290512d1a07b283.tar.gz | |
fix unsafety in command execution
Diffstat (limited to 'src/run')
| -rw-r--r-- | src/run/mod.rs | 16 |
1 files changed, 8 insertions, 8 deletions
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<u8>) { 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<u8>) { 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<BString> = 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); } |
