File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -311,7 +311,8 @@ impl ExactSizeIterator for Args {
311
311
312
312
impl Drop for Args {
313
313
fn drop ( & mut self ) {
314
- // NULL-safe
314
+ // self.cur can be null if CommandLineToArgvW previously failed,
315
+ // but LocalFree ignores NULL pointers
315
316
unsafe { c:: LocalFree ( self . cur as * mut c_void ) ; }
316
317
}
317
318
}
@@ -322,8 +323,9 @@ pub fn args() -> Args {
322
323
let lpCmdLine = c:: GetCommandLineW ( ) ;
323
324
let szArgList = c:: CommandLineToArgvW ( lpCmdLine, & mut nArgs) ;
324
325
325
- // cur may be NULL if CommandLineToArgvW failed,
326
- // in which case the range is empty to prevent reads
326
+ // szArcList can be NULL if CommandLinToArgvW failed,
327
+ // but in that case nArgs is 0 so we won't actually
328
+ // try to read a null pointer
327
329
Args { cur : szArgList, range : 0 ..( nArgs as isize ) }
328
330
}
329
331
}
You can’t perform that action at this time.
0 commit comments