We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 6fed735 + 2148567 commit 55deea6Copy full SHA for 55deea6
src/libstd/sys/windows/os.rs
@@ -311,6 +311,8 @@ impl ExactSizeIterator for Args {
311
312
impl Drop for Args {
313
fn drop(&mut self) {
314
+ // self.cur can be null if CommandLineToArgvW previously failed,
315
+ // but LocalFree ignores NULL pointers
316
unsafe { c::LocalFree(self.cur as *mut c_void); }
317
}
318
@@ -321,6 +323,9 @@ pub fn args() -> Args {
321
323
let lpCmdLine = c::GetCommandLineW();
322
324
let szArgList = c::CommandLineToArgvW(lpCmdLine, &mut nArgs);
325
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
329
Args { cur: szArgList, range: 0..(nArgs as isize) }
330
331
0 commit comments