Skip to content

Fix dangling pointer in format_email. #614

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

Merged
merged 1 commit into from
Aug 19, 2020

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Aug 19, 2020

The code was creating an Oid object, taking a pointer to it, and then immediately dropping it. The fix is to use a local variable to hold the value.

Fixes #613

@joshtriplett
Copy link
Member

@ehuss Thanks for the fix! The same issue would apply to commit.author().raw() a few lines later, right?

@joshtriplett joshtriplett merged commit a56acdc into rust-lang:master Aug 19, 2020
@ehuss
Copy link
Contributor Author

ehuss commented Aug 19, 2020

The same issue would apply to commit.author().raw() a few lines later, right?

I don't think so. The Signature returned from commit.author() is not owned (see from_raw_const). Thus when the Signature is dropped, the raw pointer is still alive.

@joshtriplett
Copy link
Member

You're right. I was trying to see if there were other instances of this pattern in the codebase, and searched for ().raw in the process.

I wonder if there's some reasonable way we could get the compiler to identify issues like this, even though they use raw pointers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test diff::tests::format_email_simple fails, only in release mode
2 participants