diff options
| author | bors <bors@rust-lang.org> | 2015-06-23 22:03:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-06-23 22:03:04 +0000 |
| commit | 55deea606bd44022a5fe588ed506775dca3aecf7 (patch) | |
| tree | 349b5494b78c301d9564c5c38f5b2e0ebd6bd648 /src/libstd/sys | |
| parent | 6fed735b22ef66918cf78c3df9a7922df9ed7954 (diff) | |
| parent | 2148567821b0e3ff63e13b652b9b645263b70cb0 (diff) | |
| download | rust-55deea606bd44022a5fe588ed506775dca3aecf7.tar.gz rust-55deea606bd44022a5fe588ed506775dca3aecf7.zip | |
Auto merge of #26219 - Veedrac:patch-1, r=alexcrichton
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.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index 5cfc2010424..8a8cf9e7c53 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -311,6 +311,8 @@ impl ExactSizeIterator for Args { impl Drop for Args { fn drop(&mut self) { + // self.cur can be null if CommandLineToArgvW previously failed, + // but LocalFree ignores NULL pointers unsafe { c::LocalFree(self.cur as *mut c_void); } } } @@ -321,6 +323,9 @@ pub fn args() -> Args { let lpCmdLine = c::GetCommandLineW(); let szArgList = c::CommandLineToArgvW(lpCmdLine, &mut nArgs); + // 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) } } } |
