[avar2] Add v2 structure and sanitize

This commit is contained in:
Behdad Esfahbod 2022-06-28 16:42:28 -06:00
parent c9e843942e
commit c3eb6713e9
1 changed files with 31 additions and 1 deletions

View File

@ -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<DeltaSetIndexMap> varIdxMap; /* Offset from the beginning of 'avar' table. */
Offset32To<VariationStore> 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<SegmentMaps> (*map);
}
if (version.major == 2)
{
auto *v2 = (const avarV2Tail *) map;
if (unlikely (!v2->sanitize (c, this)))
return_trace (false);
}
return_trace (true);
}