From c3eb6713e90340109e1084924945d570e52bbe28 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 28 Jun 2022 16:42:28 -0600 Subject: [PATCH] [avar2] Add v2 structure and sanitize --- src/hb-ot-var-avar-table.hh | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/hb-ot-var-avar-table.hh b/src/hb-ot-var-avar-table.hh index 71d767e30..2988be626 100644 --- a/src/hb-ot-var-avar-table.hh +++ b/src/hb-ot-var-avar-table.hh @@ -28,6 +28,8 @@ #define HB_OT_VAR_AVAR_TABLE_HH #include "hb-open-type.hh" +#include "hb-ot-var-common.hh" + /* * avar -- Axis Variations @@ -40,6 +42,27 @@ namespace OT { +struct avarV2Tail +{ + friend struct avar; + + bool sanitize (hb_sanitize_context_t *c, + const void *base) const + { + TRACE_SANITIZE (this); + return_trace (varIdxMap.sanitize (c, base) && + varStore.sanitize (c, base)); + } + + protected: + Offset32To varIdxMap; /* Offset from the beginning of 'avar' table. */ + Offset32To varStore; /* Offset from the beginning of 'avar' table. */ + + public: + DEFINE_SIZE_STATIC (8); +}; + + struct AxisValueMap { bool sanitize (hb_sanitize_context_t *c) const @@ -118,7 +141,7 @@ struct avar { TRACE_SANITIZE (this); if (unlikely (!(version.sanitize (c) && - version.major == 1 && + (version.major == 1 || version.major == 2) && c->check_struct (this)))) return_trace (false); @@ -131,6 +154,13 @@ struct avar map = &StructAfter (*map); } + if (version.major == 2) + { + auto *v2 = (const avarV2Tail *) map; + if (unlikely (!v2->sanitize (c, this))) + return_trace (false); + } + return_trace (true); }