Commit 5f8f44d218c0e3d5c7c9f26ac5d04c399e58d2e7

Werner Lemberg 2015-10-01T14:16:03

[sfnt] Make `tt_cmap4_char_map_linear' faster (#46078). * src/sfnt/ttcmap.c (tt_cmap4_char_map_linear): Use inner loop to reject too large glyph indices.

diff --git a/ChangeLog b/ChangeLog
index 7e3bb45..6e58029 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-10-01  Werner Lemberg  <wl@gnu.org>
+
+	[sfnt] Make `tt_cmap4_char_map_linear' faster (#46078).
+
+	* src/sfnt/ttcmap.c (tt_cmap4_char_map_linear): Use inner loop to
+	reject too large glyph indices.
+
 2015-09-30  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
 	[smooth] Clean up worker.
diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c
index e80fc54..3e8ea83 100644
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -1115,7 +1115,11 @@
 
           gindex = TT_PEEK_USHORT( r );
           if ( gindex )
+          {
             gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU;
+            if ( gindex >= (FT_UInt)face->root.num_glyphs )
+              gindex = 0;
+          }
         }
         else
         {