mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 14:31:10 +01:00
_hb_graphite2_shape() grows buffer->info with ensure() (a plain realloc) and then fills each output glyph field by field, but never assigned hb_glyph_info_t::mask. Entries beyond the original text length therefore kept uninitialised heap bytes (or, in a reused buffer, the mask from a previous shaping run); clear_glyph_flags() only rewrites the low three bits, so hb_buffer_get_glyph_infos() handed the stale bits 3-31 to the caller. Shaping output is correct (every in-tree reader masks down to HB_GLYPH_FLAG_DEFINED), but valgrind/MSan flag the uninitialised bytes and code reading the private field sees values that vary run to run. Set info->mask = 0 in the fill loop, next to the other fields. That matches what hb_buffer_t::add() starts from and what the OpenType shaper returns after hb_propagate_flags(), so the subsequent clear_glyph_flags()/unsafe_to_break() operate on a defined value and shaping output is unchanged. No other shaper needs the change. Adds test_graphite2_inserted_glyph_masks, which first runs the OpenType shaper so a removed default-ignorable leaves a non-zero mask in the buffer storage, then checks that every glyph the Graphite shaper adds for U+0622 comes back with nothing but glyph-flag bits. Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-UDVJURW0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>