Comment for #26196.
Fixes #26196. Alternatively we could explicitly check and complain (eg. panic), but I don't see the value-add.
This commit is contained in:
parent
7e9a8e322a
commit
b107af3ada
1 changed files with 3 additions and 0 deletions
|
|
@ -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) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue