Fix awful confusion between lookup format and subtable format

As reported by John Daggett.
This commit is contained in:
Behdad Esfahbod 2010-05-10 21:39:24 -04:00
parent 458ecbb60b
commit fe9bc070e1
2 changed files with 14 additions and 14 deletions

View File

@ -1458,10 +1458,10 @@ struct PosLookupSubTable
} }
} }
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context, unsigned int lookup_type) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!u.format.sanitize (context)) return false; if (!u.sub_format.sanitize (context)) return false;
switch (u.format) { switch (lookup_type) {
case Single: return u.single.sanitize (context); case Single: return u.single.sanitize (context);
case Pair: return u.pair.sanitize (context); case Pair: return u.pair.sanitize (context);
case Cursive: return u.cursive.sanitize (context); case Cursive: return u.cursive.sanitize (context);
@ -1477,7 +1477,7 @@ struct PosLookupSubTable
private: private:
union { union {
USHORT format; USHORT sub_format;
SinglePos single; SinglePos single;
PairPos pair; PairPos pair;
CursivePos cursive; CursivePos cursive;
@ -1489,7 +1489,7 @@ struct PosLookupSubTable
ExtensionPos extension; ExtensionPos extension;
} u; } u;
public: public:
DEFINE_SIZE_UNION (2, format); DEFINE_SIZE_UNION (2, sub_format);
}; };
@ -1563,7 +1563,7 @@ struct PosLookup : Lookup
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (unlikely (!Lookup::sanitize (context))) return false; if (unlikely (!Lookup::sanitize (context))) return false;
OffsetArrayOf<PosLookupSubTable> &list = CastR<OffsetArrayOf<PosLookupSubTable> > (subTable); OffsetArrayOf<PosLookupSubTable> &list = CastR<OffsetArrayOf<PosLookupSubTable> > (subTable);
return list.sanitize (context, this); return list.sanitize (context, this, get_type ());
} }
}; };
@ -1611,7 +1611,7 @@ inline bool ExtensionPos::sanitize (hb_sanitize_context_t *context)
if (unlikely (!Extension::sanitize (context))) return false; if (unlikely (!Extension::sanitize (context))) return false;
unsigned int offset = get_offset (); unsigned int offset = get_offset ();
if (unlikely (!offset)) return true; if (unlikely (!offset)) return true;
return StructAtOffset<PosLookupSubTable> (this, offset).sanitize (context); return StructAtOffset<PosLookupSubTable> (this, offset).sanitize (context, get_type ());
} }
static inline bool position_lookup (hb_apply_context_t *context, unsigned int lookup_index) static inline bool position_lookup (hb_apply_context_t *context, unsigned int lookup_index)

View File

@ -730,10 +730,10 @@ struct SubstLookupSubTable
} }
} }
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context, unsigned int lookup_type) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!u.format.sanitize (context)) return false; if (!u.sub_format.sanitize (context)) return false;
switch (u.format) { switch (lookup_type) {
case Single: return u.single.sanitize (context); case Single: return u.single.sanitize (context);
case Multiple: return u.multiple.sanitize (context); case Multiple: return u.multiple.sanitize (context);
case Alternate: return u.alternate.sanitize (context); case Alternate: return u.alternate.sanitize (context);
@ -748,7 +748,7 @@ struct SubstLookupSubTable
private: private:
union { union {
USHORT format; USHORT sub_format;
SingleSubst single; SingleSubst single;
MultipleSubst multiple; MultipleSubst multiple;
AlternateSubst alternate; AlternateSubst alternate;
@ -759,7 +759,7 @@ struct SubstLookupSubTable
ReverseChainSingleSubst reverseChainContextSingle; ReverseChainSingleSubst reverseChainContextSingle;
} u; } u;
public: public:
DEFINE_SIZE_UNION (2, format); DEFINE_SIZE_UNION (2, sub_format);
}; };
@ -870,7 +870,7 @@ struct SubstLookup : Lookup
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (unlikely (!Lookup::sanitize (context))) return false; if (unlikely (!Lookup::sanitize (context))) return false;
OffsetArrayOf<SubstLookupSubTable> &list = CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable); OffsetArrayOf<SubstLookupSubTable> &list = CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable);
return list.sanitize (context, this); return list.sanitize (context, this, get_type ());
} }
}; };
@ -918,7 +918,7 @@ inline bool ExtensionSubst::sanitize (hb_sanitize_context_t *context)
if (unlikely (!Extension::sanitize (context))) return false; if (unlikely (!Extension::sanitize (context))) return false;
unsigned int offset = get_offset (); unsigned int offset = get_offset ();
if (unlikely (!offset)) return true; if (unlikely (!offset)) return true;
return StructAtOffset<SubstLookupSubTable> (this, offset).sanitize (context); return StructAtOffset<SubstLookupSubTable> (this, offset).sanitize (context, get_type ());
} }
inline bool ExtensionSubst::is_reverse (void) const inline bool ExtensionSubst::is_reverse (void) const