Skip to content

Commit 2148567

Browse files
committed
Changed patch wording
1 parent b107af3 commit 2148567

File tree

1 file changed

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

1 file changed

+5
-3
lines changed

src/libstd/sys/windows/os.rs

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

312312
impl Drop for Args {
313313
fn drop(&mut self) {
314-
// NULL-safe
314+
// self.cur can be null if CommandLineToArgvW previously failed,
315+
// but LocalFree ignores NULL pointers
315316
unsafe { c::LocalFree(self.cur as *mut c_void); }
316317
}
317318
}
@@ -322,8 +323,9 @@ pub fn args() -> Args {
322323
let lpCmdLine = c::GetCommandLineW();
323324
let szArgList = c::CommandLineToArgvW(lpCmdLine, &mut nArgs);
324325

325-
// cur may be NULL if CommandLineToArgvW failed,
326-
// in which case the range is empty to prevent reads
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
327329
Args { cur: szArgList, range: 0..(nArgs as isize) }
328330
}
329331
}

0 commit comments

Comments
 (0)