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

Remove an unsafe block #178

Merged
merged 1 commit into from
Jul 21, 2024
Merged

Remove an unsafe block #178

merged 1 commit into from
Jul 21, 2024

Conversation

ChayimFriedman2
Copy link
Contributor

@ChayimFriedman2 ChayimFriedman2 commented Jul 21, 2024

The code was incorrect, and it caused UB in the wild, because BytesMut::reserve() reserves len+X, not capacity+X.

But even without that bug, this unsafe code was UB, since treating uninitialized integers as initialized is UB.

Fortunately, the unsafe code can be eliminated completely, and yet without zeroing the array.

You may consider yanking the affected versions.

The code was incorrect, and [it caused UB in the wild](https://stackoverflow.com/q/78776053/7884305), because `BytesMut::reserve()` reserves **len**+X, not **capacity**+X.

But even without that bug, this unsafe code was UB, since [treating uninitialized integers as initialized is UB](https://doc.rust-lang.org/stable/reference/behavior-considered-undefined.html).

Fortunately, the unsafe code can be eliminated completely, and yet without zeroing the array.
@knutwalker knutwalker merged commit e404ea2 into neo4j-labs:main Jul 21, 2024
22 checks passed
knutwalker pushed a commit that referenced this pull request Jul 22, 2024
@knutwalker
Copy link
Collaborator

Thanks for fixing this!

I just released 0.7.2 with this fix and yanked all previous 0.7.x releases.

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