Skip to content

Commit b107af3

Browse files
committed
Comment for #26196.
Fixes #26196. Alternatively we could explicitly check and complain (eg. panic), but I don't see the value-add.
1 parent 7e9a8e3 commit b107af3

File tree

1 file changed

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

1 file changed

+3
-0
lines changed

src/libstd/sys/windows/os.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ impl ExactSizeIterator for Args {
311311

312312
impl Drop for Args {
313313
fn drop(&mut self) {
314+
// NULL-safe
314315
unsafe { c::LocalFree(self.cur as *mut c_void); }
315316
}
316317
}
@@ -321,6 +322,8 @@ pub fn args() -> Args {
321322
let lpCmdLine = c::GetCommandLineW();
322323
let szArgList = c::CommandLineToArgvW(lpCmdLine, &mut nArgs);
323324

325+
// cur may be NULL if CommandLineToArgvW failed,
326+
// in which case the range is empty to prevent reads
324327
Args { cur: szArgList, range: 0..(nArgs as isize) }
325328
}
326329
}

0 commit comments

Comments
 (0)