diff options
| author | Joshua Landau <joshua@landau.ws> | 2015-06-11 18:10:25 +0100 |
|---|---|---|
| committer | Joshua Landau <joshua@landau.ws> | 2015-06-11 18:10:25 +0100 |
| commit | 2148567821b0e3ff63e13b652b9b645263b70cb0 (patch) | |
| tree | ffd3a3b18dc1398fc870d702c00dc32df5632492 /src/libstd/sys | |
| parent | b107af3ada920f6902ee4cbed08858013ea60177 (diff) | |
| download | rust-2148567821b0e3ff63e13b652b9b645263b70cb0.tar.gz rust-2148567821b0e3ff63e13b652b9b645263b70cb0.zip | |
Changed patch wording
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/windows/os.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index 522831a62b6..8a8cf9e7c53 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -311,7 +311,8 @@ impl ExactSizeIterator for Args { impl Drop for Args { fn drop(&mut self) { - // NULL-safe + // self.cur can be null if CommandLineToArgvW previously failed, + // but LocalFree ignores NULL pointers unsafe { c::LocalFree(self.cur as *mut c_void); } } } @@ -322,8 +323,9 @@ pub fn args() -> Args { let lpCmdLine = c::GetCommandLineW(); let szArgList = c::CommandLineToArgvW(lpCmdLine, &mut nArgs); - // cur may be NULL if CommandLineToArgvW failed, - // in which case the range is empty to prevent reads + // szArcList can be NULL if CommandLinToArgvW failed, + // but in that case nArgs is 0 so we won't actually + // try to read a null pointer Args { cur: szArgList, range: 0..(nArgs as isize) } } } |
