about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorJoshua Landau <joshua@landau.ws>2015-06-11 14:23:51 +0100
committerJoshua Landau <joshua@landau.ws>2015-06-11 14:23:51 +0100
commitb107af3ada920f6902ee4cbed08858013ea60177 (patch)
tree81b272ec081423299a9a1d3c6f8c56bc7f50ee9c /src/libstd/sys
parent7e9a8e322a62e594146b2349ff427148ec7922ae (diff)
downloadrust-b107af3ada920f6902ee4cbed08858013ea60177.tar.gz
rust-b107af3ada920f6902ee4cbed08858013ea60177.zip
Comment for #26196.
Fixes #26196.

Alternatively we could explicitly check and complain (eg. panic), but I don't see the value-add.
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/windows/os.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs
index 5cfc2010424..522831a62b6 100644
--- a/src/libstd/sys/windows/os.rs
+++ b/src/libstd/sys/windows/os.rs
@@ -311,6 +311,7 @@ impl ExactSizeIterator for Args {
 
 impl Drop for Args {
     fn drop(&mut self) {
+        // NULL-safe
         unsafe { c::LocalFree(self.cur as *mut c_void); }
     }
 }
@@ -321,6 +322,8 @@ 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
         Args { cur: szArgList, range: 0..(nArgs as isize) }
     }
 }