Skip to content

CFCharacterSet: fix off-by-one in character range operations - #94

Merged
rfm merged 1 commit into
gnustep:masterfrom
DTW-Thalion:fix/cfcharacterset-range
Sep 6, 2026
Merged

rfm merged 1 commit into
gnustep:masterfrom
DTW-Thalion:fix/cfcharacterset-range

Conversation

@DTW-Thalion

Copy link
Copy Markdown
Contributor

CFCharacterSetCreateWithCharactersInRange, CFCharacterSetAddCharactersInRange and
CFCharacterSetRemoveCharactersInRange passed range.location + range.length as the
end bound to uset_open / uset_addRange / uset_removeRange, but those ICU functions
take an inclusive end, so each operation covered one extra character. For example
CFCharacterSetCreateWithCharactersInRange(CFRangeMake(0x1F600, 1)) contained both
U+1F600 and U+1F601. Pass the last index of the range, and treat an empty range as
empty. Verified against Apple CoreFoundation.

CFCharacterSetCreateWithCharactersInRange, CFCharacterSetAddCharactersInRange and
CFCharacterSetRemoveCharactersInRange passed range.location + range.length to the
ICU set functions, whose end bound is inclusive, so each included one extra
character. Pass the last index of the range instead, and treat an empty range as
empty.
@DTW-Thalion
DTW-Thalion force-pushed the fix/cfcharacterset-range branch from 1129ff2 to e891d06 Compare July 24, 2026 15:16
@DTW-Thalion DTW-Thalion reopened this Jul 24, 2026
@DTW-Thalion DTW-Thalion reopened this Jul 27, 2026
@rfm
rfm merged commit 807d71a into gnustep:master Sep 6, 2026
3 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants