[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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
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;