-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Comment for #26196. #26219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comment for #26196. #26219
Conversation
Fixes rust-lang#26196. Alternatively we could explicitly check and complain (eg. panic), but I don't see the value-add.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pcwalton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@@ -311,6 +311,7 @@ impl ExactSizeIterator for Args { | |||
|
|||
impl Drop for Args { | |||
fn drop(&mut self) { | |||
// NULL-safe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change this to something like:
Note that
self.cur
can be null (CommandLineToArgvW
previously failed), butLocalFree
ignores NULL pointers
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs don't guarantee that nargs is 0 on error, not what I can find. Why not check for error and set nargs to zero in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is initialized to 0 and the function probably won't touch it in the error case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but to be safe you might not want to rely on a “probably”.
Fixes #26196. Alternatively we could explicitly check and complain (eg. panic), but I don't see the value-add.
Fixes #26196.
Alternatively we could explicitly check and complain (eg. panic), but I don't see the value-add.