[subset] Reject failed glyph sets before allocating flat maps (#6409)

An allocation failure can leave out-of-range glyph IDs in the GSUB
set because subsequent range deletions are skipped. Building the flat
glyph map from that set can then request several gigabytes before the
set's error state is checked.

Reject an errored GSUB glyph set before sizing the flat map, and add
the minimized fuzzer testcase to the regression corpus.

Tested with the full Meson suite (292 passed, one skipped) and 100
reproducer runs under ASan/UBSan with failing allocations enabled.

Fixes: https://oss-fuzz.com/testcase-detail/5574495277219840
Assisted-by: OpenAI Codex
This commit is contained in:
Behdad Esfahbod authored and GitHub committed 2026-10-18 18:01:11 -06:00
1 parent 54d71be605
commit 8abfd0d16e
2 files changed
+3

No files matched your search

+3
View File
@@ -528,6 +528,9 @@ _create_glyph_map_gsub (const hb_set_t* glyph_set_gsub,
hb_map_t* out,
hb_vector_t<hb_codepoint_t>* out_flat)
{
if (unlikely (glyph_set_gsub->in_error ()))
return false;
hb_codepoint_t max_gid = HB_SET_VALUE_INVALID;
hb_set_previous (glyph_set_gsub, &max_gid);
unsigned flat_size = max_gid == HB_SET_VALUE_INVALID ? 0 : max_gid + 1;