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

unsafety in text fix #746

Merged
merged 2 commits into from Sep 15, 2023
Merged

unsafety in text fix #746

merged 2 commits into from Sep 15, 2023

Conversation

sanbox-irl
Copy link
Member

@sanbox-irl sanbox-irl commented Sep 12, 2023

Hiya! Long time no see.

There's some unsafety in our UiBuffer in particular situations -- an additionally makes clippy stop yelling at us.

The buffer is fairly simple -- it's just a giant list of bytes which we write user provided strings and then append a null byte to afterwards. We hand Dear Imgui a pointer to a position within that buffer (the start of the string the user gave), which it reads naively until it hits the null byte we gave.

This works fine, but since we use a Vec, multiple pushes can cause the backing buffer to get reallocated. We in a few places, notably the Tree structures, held onto invalid pointers past pushes.

This PR fixes those unsafety issues. There is perhaps a better way to architect this to use the borrow checker more easily to our advantage, but I haven't done that exploration work here.

@sanbox-irl sanbox-irl marked this pull request as ready for review September 12, 2023 17:15
@sanbox-irl
Copy link
Member Author

Goign to go ahead and merge this -- we should also update MSRV in the future

@sanbox-irl sanbox-irl merged commit 50e166e into main Sep 15, 2023
5 of 8 checks passed
@sanbox-irl sanbox-irl deleted the unsafety-text-fix-upstream branch September 15, 2023 03:03
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.

None yet

1 participant