LibGfx: Fix off-by-one in opentype cmap format 6 parsing

Fixes asserts when rendering 0000037.pdf, 0000116.pdf, 0000463.pdf,
0000483.pdf, 0000506.pdf, and 0000938.pdf in 0000.zip from the
pdfa dataset.
This commit is contained in:
Nico Weber 2023-10-26 08:37:41 -07:00 committed by Andreas Kling
parent 2ef24e883c
commit 88bd7d83ad
Notes: sideshowbarker 2024-07-17 02:38:39 +09:00

View file

@ -144,7 +144,7 @@ u32 Cmap::Subtable::glyph_id_for_code_point_table_6(u32 code_point) const
u32 entry_count = be_u16(m_slice.offset((u32)Table6Offsets::EntryCount));
u32 code_offset = code_point - first_code;
if (code_offset > entry_count)
if (code_offset >= entry_count)
return 0;
return be_u16(m_slice.offset((u32)Table6Offsets::GlyphIdArray + code_offset * 2));