Skip to content

Commit 55deea6

Browse files
committed
Auto merge of #26219 - Veedrac:patch-1, r=alexcrichton
Fixes #26196. Alternatively we could explicitly check and complain (eg. panic), but I don't see the value-add.
2 parents 6fed735 + 2148567 commit 55deea6

File tree

1 file changed

+5
-0
lines changed
  • src/libstd/sys/windows

1 file changed

+5
-0
lines changed

src/libstd/sys/windows/os.rs

+5
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ impl ExactSizeIterator for Args {
311311

312312
impl Drop for Args {
313313
fn drop(&mut self) {
314+
// self.cur can be null if CommandLineToArgvW previously failed,
315+
// but LocalFree ignores NULL pointers
314316
unsafe { c::LocalFree(self.cur as *mut c_void); }
315317
}
316318
}
@@ -321,6 +323,9 @@ pub fn args() -> Args {
321323
let lpCmdLine = c::GetCommandLineW();
322324
let szArgList = c::CommandLineToArgvW(lpCmdLine, &mut nArgs);
323325

326+
// szArcList can be NULL if CommandLinToArgvW failed,
327+
// but in that case nArgs is 0 so we won't actually
328+
// try to read a null pointer
324329
Args { cur: szArgList, range: 0..(nArgs as isize) }
325330
}
326331
}

0 commit comments

Comments
 (0)