From b107af3ada920f6902ee4cbed08858013ea60177 Mon Sep 17 00:00:00 2001 From: Joshua Landau Date: Thu, 11 Jun 2015 14:23:51 +0100 Subject: Comment for #26196. Fixes #26196. Alternatively we could explicitly check and complain (eg. panic), but I don't see the value-add. --- src/libstd/sys/windows/os.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/libstd/sys') 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) } } } -- cgit 1.4.1-3-g733a5