Guard GPOS mark attachment against attach_chain overflow - #480
Merged
Merged
Conversation
A mark more than i16::MAX glyphs after its base stored a truncated attach_chain and was positioned relative to the wrong glyph. HarfBuzz checks for this and leaves the mark unattached (MarkArray.hh). Do the same, as harfbuzz#411 does for cursive attachment.
Member
|
Thanks. |
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.
Mark attachment stores the distance to the base in
attach_chainwith(glyph_pos as isize - idx as isize) as i16(harfrust/src/hb/ot/gpos/mark.rs:85), which truncates when a mark is more thani16::MAXglyphs after its base. HarfBuzz checks this inMarkArray::apply(MarkArray.hh, from harfbuzz#5636) and leaves the mark unattached; #411 ported the cursive half of that change.xfollowed by 33000 U+0301 with--features=-mkmkandtests/fonts/rb_custom/BungeeTint-Regular.ttf: HarfBuzz 14.5 attaches the first 32768 marks at@-369,0and leaves the remaining 232 at@0,0; main places those 232 at@368,0(the chain wraps to a later glyph).This checks the distance with
i16::try_frombefore writing the offsets and, on overflow, setsattach_chainto 0 and moves on, as HarfBuzz does. Marks within range are unchanged.mark_too_far_from_its_base_is_left_unattachedsits next to the issue 384 tests intests/shaping/regressions.rs; it fails on main.cargo fmt --check,cargo clippy -p harfrust --all-features --all-targets -D warningsandcargo test -p harfrustpass; I did not run the MSRV, no-default-features, icu or thumbv7em jobs. CHANGELOG entry added under Unreleased, as in #411.Written with AI assistance (Claude); I have reviewed the change.