Skip to content

release/2.2: Fix off-by-one errors in CollationSpecialPrimariesValidated#8081

Merged
sffc merged 1 commit into
unicode-org:release/2.2from
sffc:fix-collator-2.2
Jun 19, 2026
Merged

release/2.2: Fix off-by-one errors in CollationSpecialPrimariesValidated#8081
sffc merged 1 commit into
unicode-org:release/2.2from
sffc:fix-collator-2.2

Conversation

@sffc

@sffc sffc commented Jun 15, 2026

Copy link
Copy Markdown
Member

Port of #8075 to the release/2.2 branch.

Fixes a critical off-by-one bug in icu_collator 2.2.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 PR also includes the regression test test_shifted_max_variable_currency.

🤖 This pull request was created by an AI agent working with @sffc.

Changelog

  • Fix panic when using AlternateHandling::Shifted with MaxVariable::Currency (off-by-one in special primaries validation).

@sffc sffc changed the title Fix off-by-one errors in CollationSpecialPrimariesValidated (2.2) release/2.2: Fix off-by-one errors in CollationSpecialPrimariesValidated Jun 15, 2026
@sffc sffc marked this pull request as ready for review June 15, 2026 23:14
@sffc sffc requested review from echeran and hsivonen as code owners June 15, 2026 23:14
@sffc sffc requested a review from Manishearth June 15, 2026 23:14
sffc added a commit that referenced this pull request Jun 16, 2026
…ariable::Currency (#8080)

See #8075, #8081

Co-authored-by: Gemini <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@sffc sffc force-pushed the fix-collator-2.2 branch 3 times, most recently from 95cd143 to dc7c510 Compare June 16, 2026 01:42
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>
@sffc sffc force-pushed the fix-collator-2.2 branch from dc7c510 to 1cfbfed Compare June 18, 2026 01:27
@sffc sffc requested a review from robertbastian June 18, 2026 01:32
@sffc sffc merged commit 2454571 into unicode-org:release/2.2 Jun 19, 2026
33 checks passed
@sffc sffc deleted the fix-collator-2.2 branch June 19, 2026 04:01
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.

2 participants