diff --git a/src/OT/Var/VARC/VARC.cc b/src/OT/Var/VARC/VARC.cc index 1afb57111..899b2f17f 100644 --- a/src/OT/Var/VARC/VARC.cc +++ b/src/OT/Var/VARC/VARC.cc @@ -192,17 +192,22 @@ VarComponent::get_path_at (hb_font_t *font, // Axis values - hb_vector_t axisIndices; + hb_array_t axisIndices; hb_vector_t axisValues; if (flags & (unsigned) flags_t::HAVE_AXES) { unsigned axisIndicesIndex; READ_UINT32VAR (axisIndicesIndex); axisIndices = (&VARC+VARC.axisIndicesList)[axisIndicesIndex]; - axisValues.resize (axisIndices.length); - const HBUINT8 *p = (const HBUINT8 *) record; - TupleValues::decompile (p, axisValues, (const HBUINT8 *) end); - record += (const unsigned char *) p - record; + if (axisValues.resize (axisIndices.length)) + { + if (unlikely (unsigned (end - record) < axisIndices.length * sizeof (HBINT16))) + return hb_ubytes_t (); + const HBINT16 *base = (const HBINT16 *) record; + for (unsigned i = 0; i < axisIndices.length; i++) + axisValues.arrayZ[i] = base[i]; + } + record += axisIndices.length * sizeof (HBINT16); } // Apply variations if any diff --git a/src/OT/Var/VARC/VARC.hh b/src/OT/Var/VARC/VARC.hh index d60f7b0c2..d91e9750e 100644 --- a/src/OT/Var/VARC/VARC.hh +++ b/src/OT/Var/VARC/VARC.hh @@ -178,7 +178,7 @@ struct VARC Offset32To coverage; Offset32To varStore; Offset32To conditionList; - Offset32To axisIndicesList; + Offset32To axisIndicesList; Offset32To*/> glyphRecords; public: DEFINE_SIZE_STATIC (24); diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index a52b65b5e..8480a04f7 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -1879,16 +1879,20 @@ struct TupleList : CFF2Index } }; -struct FloatTupleList : CFF2Index +template +struct TypedTupleList : CFF2Index { - hb_array_t operator [] (unsigned i) const + hb_array_t operator [] (unsigned i) const { auto bytes = CFF2Index::operator [] (i); - return hb_array (&StructAtOffsetUnaligned(bytes.arrayZ, 0), - bytes.length / sizeof (float)); + return hb_array (&StructAtOffsetUnaligned(bytes.arrayZ, 0), + bytes.length / hb_static_size (Type)); } }; +using Int16TupleList = TypedTupleList; +using FloatTupleList = TypedTupleList; + } /* namespace OT */