release/2.2: Fix off-by-one errors in CollationSpecialPrimariesValidated#8081
Merged
Conversation
This was referenced Jun 15, 2026
95cd143 to
dc7c510
Compare
Fixes a critical off-by-one bug in icu_collator 2.1.x that causes a panic when using AlternateHandling::Shifted with MaxVariable::Currency. When converting CollationSpecialPrimaries to CollationSpecialPrimariesValidated, the last_primaries vector was incorrectly truncated to MaxVariable::Currency as usize (3) instead of MaxVariable::Currency as usize + 1 (4). This resulted in last_primaries lacking the 4th element (index 3, for Currency), causing a panic (unwrap on None) during comparison when last_primary_for_group was called. Additionally, compressible_bytes extraction was misaligned by one index and failed the length check, causing it to always fall back to hardcoded defaults. This commit squashes the fix and the regression test into a single clean commit. Co-authored-by: Gemini <176961590+gemini-code-assist[bot]@users.noreply.github.com>
robertbastian
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of #8075 to the
release/2.2branch.Fixes a critical off-by-one bug in
icu_collator2.2.x that causes a panic when usingAlternateHandling::ShiftedwithMaxVariable::Currency.When converting
CollationSpecialPrimariestoCollationSpecialPrimariesValidated, thelast_primariesvector was incorrectly truncated toMaxVariable::Currency as usize(3) instead ofMaxVariable::Currency as usize + 1(4). This resulted inlast_primarieslacking the 4th element (index 3, forCurrency), causing a panic (unwraponNone) during comparison whenlast_primary_for_groupwas called.Additionally,
compressible_bytesextraction was misaligned by one index and failed the length check, causing it to always fall back to hardcoded defaults.This PR also includes the regression test
test_shifted_max_variable_currency.🤖 This pull request was created by an AI agent working with @sffc.
Changelog
AlternateHandling::ShiftedwithMaxVariable::Currency(off-by-one in special primaries validation).