Skip to content

Commit 816e4ec

Browse files
committed
FIX: assert >= 1 in process::command::arg_set()
We do not want to set argv[0] here. This needs to be asserted at any time. Assertion for the index within range is only a debug_assert becasue its a mere helpful error message, indexing later would assert on out of range access anyway.
1 parent 6a10a48 commit 816e4ec

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/std/src/sys/unix/process/process_common.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ impl Command {
200200
}
201201

202202
pub fn arg_set(&mut self, index: usize, arg: &OsStr) {
203-
debug_assert!(index >= 1 && index < self.args.len(), "Index out of range");
203+
assert!(index >= 1, "Index must be >= 1");
204+
debug_assert!(index < self.args.len(), "Index out of range");
204205
let arg = os2c(arg, &mut self.saw_nul);
205206
self.argv.0[index] = arg.as_ptr();
206207
self.args[index] = arg;

0 commit comments

Comments
 (0)