Skip to content

fix: length overflow on non-64-bit ZST - #625

Merged
alejandro-vaz merged 2 commits into
smallvec:v2from
alejandro-vaz:length-overflow
Sep 21, 2026
Merged

alejandro-vaz merged 2 commits into
smallvec:v2from
alejandro-vaz:length-overflow

Conversation

@alejandro-vaz

@alejandro-vaz alejandro-vaz commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

this fixes the old overflow checks only enabled with debug assertions and on non-64-bit machines to properly handle ZSTs

before, since Self::MAX_LEN would equal usize::MAX, the saturating addition would never amount to anything greater that Self::MAX_LEN, and thus succeed and overflow would occur on the proper addition

this is now fixed with a checked addition and an additional branch

closes #621

@alejandro-vaz alejandro-vaz self-assigned this Sep 19, 2026
@alejandro-vaz
alejandro-vaz requested a review from jdm September 20, 2026 09:21
@alejandro-vaz
alejandro-vaz marked this pull request as ready for review September 20, 2026 09:24
@alejandro-vaz
alejandro-vaz added this pull request to the merge queue Sep 21, 2026
Merged via the queue into smallvec:v2 with commit 0446bf4 Sep 21, 2026
6 checks passed
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.

fix ZST non-64-bit TaggedLen overflow

2 participants