From f8c3df7d4a685bb86a1c15a5ef95485e8ef30305 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 7 Nov 2018 12:48:06 -0500 Subject: [PATCH] [kern/kerx] Minor --- src/hb-aat-layout-kerx-table.hh | 5 +++-- src/hb-ot-kern-table.hh | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index 9a221bc5a..636380260 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -852,6 +852,7 @@ public: struct kerx { static const hb_tag_t tableTag = HB_AAT_TAG_kerx; + static const uint16_t minVersion = 2; inline bool has_data (void) const { return version != 0; } @@ -898,8 +899,7 @@ struct kerx inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - if (!version.sanitize (c) || version < 2 || - !tableCount.sanitize (c)) + if (!version.sanitize (c) || version < minVersion || !tableCount.sanitize (c)) return_trace (false); const KerxSubTable *st = &firstTable; @@ -921,6 +921,7 @@ struct kerx HBUINT32 tableCount; /* The number of subtables included in the extended kerning * table. */ KerxSubTable firstTable; /* Subtables. */ + UnsizedArrayOf dataZ; /*subtableGlyphCoverageArray*/ /* Only if version >= 3. We don't use. */ public: diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh index 89da9e36f..538451195 100644 --- a/src/hb-ot-kern-table.hh +++ b/src/hb-ot-kern-table.hh @@ -170,7 +170,7 @@ struct KernTable int v = 0; const SubTable *st = CastP (&thiz()->dataZ); - unsigned int count = thiz()->nTables; + unsigned int count = thiz()->tableCount; for (unsigned int i = 0; i < count; i++) { if ((st->u.header.coverage & (st->u.header.Variation | st->u.header.CrossStream)) || @@ -188,7 +188,7 @@ struct KernTable c->set_lookup_index (0); const SubTable *st = CastP (&thiz()->dataZ); - unsigned int count = thiz()->nTables; + unsigned int count = thiz()->tableCount; st = CastP (&thiz()->dataZ); for (unsigned int i = 0; i < count; i++) { @@ -216,14 +216,15 @@ struct KernTable inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - if (unlikely (!c->check_struct (thiz()) || - thiz()->version != T::VERSION)) + if (unlikely (!thiz()->version.sanitize (c) || + thiz()->version < T::minVersion || + !thiz()->tableCount.sanitize (c))) return_trace (false); typedef KernSubTable SubTable; const SubTable *st = CastP (&thiz()->dataZ); - unsigned int count = thiz()->nTables; + unsigned int count = thiz()->tableCount; for (unsigned int i = 0; i < count; i++) { if (unlikely (!st->sanitize (c))) @@ -239,7 +240,7 @@ struct KernOT : KernTable { friend struct KernTable; - static const uint16_t VERSION = 0x0000u; + static const uint16_t minVersion = 0; struct SubTableHeader { @@ -275,7 +276,7 @@ struct KernOT : KernTable protected: HBUINT16 version; /* Version--0x0000u */ - HBUINT16 nTables; /* Number of subtables in the kerning table. */ + HBUINT16 tableCount; /* Number of subtables in the kerning table. */ UnsizedArrayOf dataZ; public: DEFINE_SIZE_ARRAY (4, dataZ); @@ -285,7 +286,7 @@ struct KernAAT : KernTable { friend struct KernTable; - static const uint32_t VERSION = 0x00010000u; + static const uint32_t minVersion = 0x00010000u; struct SubTableHeader { @@ -320,7 +321,7 @@ struct KernAAT : KernTable protected: HBUINT32 version; /* Version--0x00010000u */ - HBUINT32 nTables; /* Number of subtables in the kerning table. */ + HBUINT32 tableCount; /* Number of subtables in the kerning table. */ UnsizedArrayOf dataZ; public: DEFINE_SIZE_ARRAY (8, dataZ);