Commit 565f5a7d19d23aa7b3d6f917e5ef6b297b89f384

Wojciech Mamrak 2017-03-27T09:19:14

[sfnt] Minor improvement for handling kern tables. * src/sfnt/ttkern.c (tt_face_load_kern): Don't check for cross-stream kerning tables since we reject format 2 tables later on anyways. Modify code for limit test... (tt_face_get_kerning): ... to avoid a limit test here.

diff --git a/ChangeLog b/ChangeLog
index 1bc0dde..1e5eee6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2017-03-27  Wojciech Mamrak  <wmamrak@gmail.com>
+
+	[sfnt] Minor improvement for handling kern tables.
+
+	* src/sfnt/ttkern.c (tt_face_load_kern): Don't check for
+	cross-stream kerning tables since we reject format 2 tables later
+	on anyways.
+	Modify code for limit test...
+	(tt_face_get_kerning): ... to avoid a limit test here.
+
 2017-03-27  Werner Lemberg  <wl@gnu.org>
 
 	[pcf] Fix compiler warnings.
diff --git a/src/sfnt/ttkern.c b/src/sfnt/ttkern.c
index 78dc5eb..c97e578 100644
--- a/src/sfnt/ttkern.c
+++ b/src/sfnt/ttkern.c
@@ -108,8 +108,8 @@
         p_next = p_limit;
 
       /* only use horizontal kerning tables */
-      if ( ( coverage & ~8U ) != 0x0001 ||
-           p + 8 > p_limit              )
+      if ( ( coverage & 3U ) != 0x0001 ||
+           p + 8 > p_next              )
         goto NextTable;
 
       num_pairs = FT_NEXT_USHORT( p );
@@ -214,8 +214,7 @@
       if ( ( face->kern_avail_bits & mask ) == 0 )
         goto NextTable;
 
-      if ( p + 8 > next )
-        goto NextTable;
+      FT_ASSERT( p + 8 <= next ); /* tested in tt_face_load_kern */
 
       num_pairs = FT_NEXT_USHORT( p );
       p        += 6;