* src/base/ftobjs.c (ft_open_face_internal): Properly guard `face_index`.

We must ensure that the cast to `FT_Int` doesn't change the sign.

Fixes #1139.
This commit is contained in:
Werner Lemberg 2022-03-19 06:40:17 +01:00
parent 53dfdcd819
commit 22a0cccb4d
1 changed files with 9 additions and 0 deletions

View File

@ -2527,6 +2527,15 @@
#endif #endif
/* only use lower 31 bits together with sign bit */
if ( face_index > 0 )
face_index &= 0x7FFFFFFFL;
else
{
face_index &= 0x7FFFFFFFL;
face_index = -face_index;
}
#ifdef FT_DEBUG_LEVEL_TRACE #ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE3(( "FT_Open_Face: " )); FT_TRACE3(( "FT_Open_Face: " ));
if ( face_index < 0 ) if ( face_index < 0 )