Skip to content

fix: fix CompactString::try_with_capacity is unsound - #496

Open
rhysd wants to merge 1 commit into
ParkMyCar:mainfrom
rhysd:issue-495
Open

rhysd wants to merge 1 commit into
ParkMyCar:mainfrom
rhysd:issue-495

Conversation

@rhysd

@rhysd rhysd commented Jul 14, 2026 •

Copy link
Copy Markdown

Fix #495

In release mode the assertion should check the capacity so that we can prevent the UB reported in #495.

I don't think this is a complete fix because try_with_capacity crashes with the large capacity but at least it prevents the unsoundness. The complete fix may be added later with some decisions (What error should be returned? Should Capacity::new be falliable like Capacity::try_new? etc.).

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.

CompactString::try_with_capacity is unsound in release mode

1 participant