[GSUB] Fix NULL-deref in SingleSubst get_glyph_alternates

hb_ot_layout_lookup_get_glyph_alternates() documents its alternate_glyphs
output as nullable, and the AlternateSubst path was fixed in the previous
commit.  The Single-substitution fallback paths (SingleSubstFormat1 and
SingleSubstFormat2, used when the queried lookup is a single-substitution)
had the same defect: they gated the write on

    if (alternate_count && *alternate_count)

and then did *alternate_glyphs = glyph_id without checking alternate_glyphs.
Passing a NULL alternate_glyphs with a non-NULL, non-zero count on a covered
glyph therefore wrote through NULL and crashed.

Also require alternate_glyphs to be non-NULL before storing.

Fixes: GHSA-v5mv-8hhw-vff8
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Behdad EsfahbodandClaude Opus 4.8 committed 2026-07-08 00:46:20 -06:00
1 parent a439a61f8f
commit 7052cd343e
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -109,7 +109,7 @@ struct SingleSubstFormat1_3
return 0;
}
if (alternate_count && *alternate_count)
if (alternate_count && *alternate_count && alternate_glyphs)
{
hb_codepoint_t d = deltaGlyphID;
hb_codepoint_t mask = get_mask ();
+1 -1
View File
@@ -89,7 +89,7 @@ struct SingleSubstFormat2_4
return 0;
}
if (alternate_count && *alternate_count)
if (alternate_count && *alternate_count && alternate_glyphs)
{
glyph_id = substitute[index];