Skip to content
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

Fix read from invalidated ptr #5

Merged
merged 1 commit into from
Sep 24, 2023

Conversation

dtolnay
Copy link
Contributor

@dtolnay dtolnay commented Sep 23, 2023

The original code is UB because mem::forget(x) moves x. x is no longer located at the address pointed to by ptr. Anything else might already have been written to the original location before ptr::read runs. For example the stack frame of either mem::forget or ptr::read might partially overlap with the original location of x.

@VictorKoenders VictorKoenders merged commit f8e4ddb into bincode-org:trunk Sep 24, 2023
1 check passed
@VictorKoenders
Copy link
Contributor

Thanks!

@dtolnay dtolnay deleted the invalid branch September 24, 2023 10:43
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.

2 participants