File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -346,6 +346,14 @@ def enc(name):
346346 # Though the encoding is different, the glyph should be the same.
347347 assert unic [u ] == armn [m ]
348348
349+ # Out-of-range charmap indices must be rejected rather than indexing out of
350+ # bounds. A negative index previously passed the upper-bound-only check and
351+ # read face->charmaps[i] out of bounds.
352+ with pytest .raises (RuntimeError , match = 'exceeds the available number' ):
353+ font .set_charmap (- 1 )
354+ with pytest .raises (RuntimeError , match = 'exceeds the available number' ):
355+ font .set_charmap (font .num_charmaps )
356+
349357
350358_expected_sfnt_names = {
351359 'DejaVu Sans' : {
Original file line number Diff line number Diff line change @@ -269,7 +269,7 @@ void FT2Font::_set_transform(
269269
270270void FT2Font::set_charmap (int i)
271271{
272- if (i >= face->num_charmaps ) {
272+ if (i < 0 || i >= face->num_charmaps ) {
273273 throw std::runtime_error (" i exceeds the available number of char maps" );
274274 }
275275 FT_CHECK (FT_Set_Charmap, face, face->charmaps [i]);
You can’t perform that action at this time.
0 commit comments