Skip to content

Bug fixes for StrV[Ref] #1778

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Bug fixes for StrV[Ref] #1778

wants to merge 4 commits into from

Conversation

kawadakk
Copy link
Contributor

@kawadakk kawadakk commented Aug 8, 2025

Fixes the following bugs:

  • StrV::reserve can return without actually reserving if additional is too large (>= usize::MAX - self.len()) and overflow checking is disabled
  • StrV::extend_from_slice can incorrectly skip StrV::reserve before writing elements if it is given a ZST slice containing a large number of elements (>= usize::MAX - self.len()) and overflow checking is disabled
  • StrV::extend_from_slice is not panic safe
  • <StrVRef as PartialEq<[&str]>>::eq incorrectly evaluates to false if two slices have different numbers of elements but their prefixes match

The left hand side of the condition `self.len + additional + 1 <= self.
capacity` could overflow and wrap around if `additional` was set to a
huge value, causing `reserve` to return without reserving a specified
capacity.
The left hand side of the condition `self.len + other.len() + 1 <= self.
capacity` could overflow and wrap around if `other` contained a large
number of elements, causing it to proceed to the copying code without
calling `reserve`.
We need to ensure that `self` is null-terminated even if `<S as AsRef<
str>>::as_ref` panics.
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.

1 participant