Skip to content

Commit

Permalink
Fix overflow when adding delta
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenzV committed Nov 9, 2024
1 parent 34c0701 commit 26dfc0f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/hb/ot_layout_gsubgpos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ fn apply_lookup(
//
// It should be possible to construct tests for both of these cases.

end = (end as isize + delta) as _;
end = end.saturating_add_signed(delta);
if end < match_positions[idx] {
// End might end up being smaller than match_positions[idx] if the recursed
// lookup ended up removing many items.
Expand Down
1 change: 1 addition & 0 deletions tests/custom/bugs.tests
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
tests/fonts/rb_custom/NotoSansCJK.subset1.otf;--direction rtl;U+4F60,U+597D,U+FF0C;
tests/fonts/rb_custom/OpenSans.subset1.ttf;--variations=wght=500,wdth=80;U+0065;
tests/fonts/rb_custom/NotoSansMalayalam.subset1.ttf;;U+0D38,U+0D4D,U+0D25;
Binary file not shown.
12 changes: 12 additions & 0 deletions tests/shaping/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ fn bugs_002() {
);
}

#[test]
fn bugs_003() {
assert_eq!(
shape(
"tests/fonts/rb_custom/NotoSansMalayalam.subset1.ttf",
"\u{0D38}\u{0D4D}\u{0D25}",
"",
),
"gid7=0+1891"
);
}

#[test]
fn fuzzer_001() {
assert_eq!(
Expand Down

0 comments on commit 26dfc0f

Please sign in to comment.