Files
harfbuzz/test/api
Behdad EsfahbodandClaude Opus 4.8 d52c540c7a [face-builder] Keep table tags sorted at add_table() time
_hb_face_builder_get_table_tags() copied every key out of the hash map
and qsort()ed it on each call, so a caller paging through the list (the
subsetter uses 32-entry pages in hb_subset_plan_execute_or_fail() and
_is_table_present()) paid N/32 sorts of N tags per enumeration.  With
the 65535-table face that hb_subset_preprocess() hands back this was
~25 s of CPU per hb_subset_or_fail() call.

Keep an hb_vector_t<hb_tag_t> next to the map and maintain it in
hb_face_builder_add_table(), the only place keys are inserted: a binary
search finds the slot, the vector is pre-allocated before the map is
touched so an allocation failure leaves both structures unchanged, and
the slot is opened with the same resize+memmove idiom hb-bit-set.hh
uses.  The getter becomes a sub_array() copy, so enumeration is O(page)
and the returned order is unchanged.  _hb_face_builder_data_reference_blob()
keeps its own sort, which orders by blob size, not by tag.

A regression test adds tags out of order, one of them twice, and checks
that paging with a 4-entry array returns each tag once in ascending
order.

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

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-30 15:30:37 -06:00
..
2025-04-06 18:08:50 -06:00
2026-07-30 19:02:25 -06:00
2026-09-04 14:14:49 -06:00
2026-07-31 04:31:26 +03:00
2025-04-05 22:37:10 -06:00
2020-01-31 16:37:30 -05:00
2020-01-15 13:36:01 -08:00
2025-06-08 13:43:27 +03:00