Commit Graph
12 Commits
Author SHA1 Message Date
Behdad EsfahbodandClaude Opus 4.8 f5ab3f4ca2 [test] Force the ot shaper in the cluster re-merge budget test
test_shape_overlong_cluster_remerge checks the native cluster re-merge op
budget added in hb-buffer.cc, which only the "ot" shaper exercises. Under
HB_SHAPER_LIST=harfrust the harfrust shaper handles clusters itself and
never trips that budget, so the buffer stayed allocation-successful and the
test aborted in the rust CI job. Pin the test to hb_shape_full() with an
"ot" shaper list.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-30 17:05:41 -06:00
Behdad EsfahbodandClaude Opus 4.8 6202af118b [buffer] Charge cluster re-merge walks to max_ops
The work budget (max_ops) is meant to bound every buffer pass whose
length the font or text controls, but the same-cluster walks that
re-merge a neighbouring run were never charged:

 - the backward merge in delete_glyph() (reached from an empty
   MultipleSubst Sequence);
 - its copy in delete_glyphs_inplace() (default-ignorable / AAT
   glyph deletion);
 - the "extend" and cross-buffer continuation loops in
   merge_clusters_impl() / merge_out_clusters_impl() (reached from
   the Thai/Lao shaper, the normalizer, morx ligatures, and any
   ligature/multiple substitution).

Once one long same-cluster run exists, every further merge or
deletion next to it walks the whole run again, so a single hb_shape()
call does O(N^2) work the budget never sees: e.g. U+0E01 followed by
130,000 x U+0E33 takes ~21 s.

Charge the glyphs actually walked to max_ops and fail the buffer when
the budget is gone, following shift_forward()/move_to(), and skip the
walk once the buffer has failed (delete_glyphs_inplace() and the
shaper-level merge_clusters() callers keep calling after a failure).
merge_out_clusters_impl() also gains the "cluster != ..." guards that
merge_clusters_impl() already had, so it no longer walks a run that
already holds the merged value; set_cluster() is a no-op on such a
glyph, so output is unchanged.  Verified: default-direction Thai
output is byte-identical to before at sizes that fit the budget, and
pathological inputs now end with hb_buffer_allocation_successful() ==
false, like any other max_ops exhaustion.

Regression test added to test/api/test-shape.c using a stock font.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-CQ04GDSH.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-30 15:24:10 -06:00
Behdad Esfahbod a597884edf [GPOS] Saturate immediate mark offsets
Mark-to-mark attachment can accumulate an unbounded cross-direction
offset. Clamp anchor conversion and saturate the immediate addition so
overlong mark clusters stop at hb_position_t limits instead of invoking
signed-overflow undefined behavior.

Add a regression for issue #6151 using 35,000 combining marks.

Testing: meson test -C build --print-errorlogs

Assisted-by: Codex <codex@openai.com>
2026-08-12 17:17:00 -06:00
Behdad Esfahbod 155e1e633b [test/api] Use g_assert_true instead of g_assert
The latter terminates the program. The former marks the test
as failing.
2025-04-06 03:49:15 -06:00
Behdad Esfahbod 163a66dc73 [test] Add test for aaa85931f3 2019-08-20 14:22:57 -07:00
Behdad Esfahbod 148d883680 [test] Don't call deprecated API 2019-05-13 14:34:53 -07:00
Behdad Esfahbod eb2be97f86 Port test off deprecated API 2018-10-09 07:48:52 -04:00
Behdad Esfahbod dcfcb950b8 [test] Fix -Wunused-parameter warnings 2018-09-30 18:14:50 +02:00
Ebrahim Byagowi f24b0b9728 Update the links and revive the dead ones 2018-04-12 13:44:32 +04:30
Behdad Esfahbod dd8598c1c7 [test] Pass closure to hb_font_set_glyph_func()
Exercises fix in c335fd7986
2016-02-25 11:20:05 +09:00
Behdad Esfahbod b3a2f6afba [test] Add test for cluster merging
Based on test from https://code.google.com/p/chromium/issues/detail?id=497578

Currently fails.  Basically, if there's a default_ignorable at the
start of text, and font has no space glyph, we remove the default_ignorable,
and that makes the first char in text to correspond to no cluster.

Fix coming.
2015-06-18 17:15:33 -07:00
Behdad Esfahbod 4d6dafd47f Rename test/ to test/api/ 2012-01-19 14:52:02 -05:00