Skip to content

Commit 750cd44

Browse files
committed
fix argv null terminator
1 parent af4fb66 commit 750cd44

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub fn create_ecx<'a, 'mir: 'a, 'tcx: 'mir>(
132132

133133
// FIXME: extract main source file path
134134
// Third argument (argv): &[b"foo"]
135-
const CMD: &str = "running-in-miri";
135+
const CMD: &str = "running-in-miri\0";
136136
let dest = ecx.eval_place(&mir::Place::Local(args.next().unwrap()))?;
137137
let cmd = ecx.memory_mut().allocate_static_bytes(CMD.as_bytes()).with_default_tag();
138138
let raw_str_layout = ecx.layout_of(ecx.tcx.mk_imm_ptr(ecx.tcx.types.u8))?;
@@ -150,9 +150,7 @@ pub fn create_ecx<'a, 'mir: 'a, 'tcx: 'mir>(
150150
// Store cmdline as UTF-16 for Windows GetCommandLineW
151151
{
152152
let tcx = &{ecx.tcx.tcx};
153-
let cmd_utf16: Vec<u16> = CMD.encode_utf16()
154-
.chain(Some(0)) // add 0-terminator
155-
.collect();
153+
let cmd_utf16: Vec<u16> = CMD.encode_utf16().collect();
156154
let cmd_ptr = ecx.memory_mut().allocate(
157155
Size::from_bytes(cmd_utf16.len() as u64 * 2),
158156
Align::from_bytes(2).unwrap(),

0 commit comments

Comments
 (0)