Remove SANITIZE_WITH_BASE

This commit is contained in:
Behdad Esfahbod 2010-05-06 12:55:14 -04:00
parent f5fab0c718
commit 41a93d2c1f
7 changed files with 98 additions and 101 deletions

View File

@ -127,7 +127,7 @@ struct TTCHeaderVersion1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, table); return table.sanitize (context, this);
} }
private: private:

View File

@ -240,8 +240,6 @@ struct hb_sanitize_context_t
#define SANITIZE(X) likely ((X).sanitize (context)) #define SANITIZE(X) likely ((X).sanitize (context))
#define SANITIZE_WITH_BASE(B,X) likely ((X).sanitize (context, CharP(B)))
#define SANITIZE_SELF() likely(context->check_range (this, sizeof (*this))) #define SANITIZE_SELF() likely(context->check_range (this, sizeof (*this)))

View File

@ -56,7 +56,7 @@ struct Record
inline bool sanitize (hb_sanitize_context_t *context, void *base) { inline bool sanitize (hb_sanitize_context_t *context, void *base) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_SELF () return SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (base, offset); && offset.sanitize (context, base);
} }
Tag tag; /* 4-byte Tag identifier */ Tag tag; /* 4-byte Tag identifier */
@ -204,8 +204,8 @@ struct Script
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, defaultLangSys) return defaultLangSys.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, langSys); && langSys.sanitize (context, this);
} }
private: private:

View File

@ -69,8 +69,8 @@ struct AttachList
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, coverage) return coverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, attachPoint); && attachPoint.sanitize (context, this);
} }
private: private:
@ -149,7 +149,7 @@ struct CaretValueFormat3
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_SELF () return SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (this, deviceTable); && deviceTable.sanitize (context, this);
} }
private: private:
@ -214,7 +214,7 @@ struct LigGlyph
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, carets); return carets.sanitize (context, this);
} }
private: private:
@ -246,8 +246,8 @@ struct LigCaretList
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, coverage) return coverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, ligGlyph); && ligGlyph.sanitize (context, this);
} }
private: private:
@ -268,7 +268,7 @@ struct MarkGlyphSetsFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, coverage); return coverage.sanitize (context, this);
} }
private: private:
@ -352,11 +352,11 @@ struct GDEF
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE (version) && likely (version.major == 1) return SANITIZE (version) && likely (version.major == 1)
&& SANITIZE_WITH_BASE (this, glyphClassDef) && glyphClassDef.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, attachList) && attachList.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, ligCaretList) && ligCaretList.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, markAttachClassDef) && markAttachClassDef.sanitize (context, this)
&& (version < 0x00010002 || SANITIZE_WITH_BASE (this, markGlyphSetsDef[0])); && (version < 0x00010002 || markGlyphSetsDef[0].sanitize (context, this));
} }
private: private:

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2007,2008,2009 Red Hat, Inc. * Copyright (C) 2007,2008,2009,2010 Red Hat, Inc.
* *
* This is part of HarfBuzz, a text shaping library. * This is part of HarfBuzz, a text shaping library.
* *
@ -106,10 +106,10 @@ struct ValueFormat : USHORT
x_scale = layout->font->x_scale; x_scale = layout->font->x_scale;
y_scale = layout->font->y_scale; y_scale = layout->font->y_scale;
/* design units -> fractional pixel */ /* design units -> fractional pixel */
if (format & xPlacement) glyph_pos->x_offset += _hb_16dot16_mul_round (x_scale, *(SHORT*)values++); if (format & xPlacement) glyph_pos->x_offset += _hb_16dot16_mul_round (x_scale, *CastP<SHORT> (values++));
if (format & yPlacement) glyph_pos->y_offset += _hb_16dot16_mul_round (y_scale, *(SHORT*)values++); if (format & yPlacement) glyph_pos->y_offset += _hb_16dot16_mul_round (y_scale, *CastP<SHORT> (values++));
if (format & xAdvance) glyph_pos->x_advance += _hb_16dot16_mul_round (x_scale, *(SHORT*)values++); if (format & xAdvance) glyph_pos->x_advance += _hb_16dot16_mul_round (x_scale, *CastP<SHORT> (values++));
if (format & yAdvance) glyph_pos->y_advance += _hb_16dot16_mul_round (y_scale, *(SHORT*)values++); if (format & yAdvance) glyph_pos->y_advance += _hb_16dot16_mul_round (y_scale, *CastP<SHORT> (values++));
if (!has_device ()) return; if (!has_device ()) return;
@ -120,21 +120,21 @@ struct ValueFormat : USHORT
/* pixel -> fractional pixel */ /* pixel -> fractional pixel */
if (format & xPlaDevice) { if (format & xPlaDevice) {
if (x_ppem) glyph_pos->x_offset += (base+*(OffsetTo<Device>*)values++).get_delta (x_ppem) << 16; else values++; if (x_ppem) glyph_pos->x_offset += (base+*CastP<OffsetTo<Device> >(values++)).get_delta (x_ppem) << 16; else values++;
} }
if (format & yPlaDevice) { if (format & yPlaDevice) {
if (y_ppem) glyph_pos->y_offset += (base+*(OffsetTo<Device>*)values++).get_delta (y_ppem) << 16; else values++; if (y_ppem) glyph_pos->y_offset += (base+*CastP<OffsetTo<Device> >(values++)).get_delta (y_ppem) << 16; else values++;
} }
if (format & xAdvDevice) { if (format & xAdvDevice) {
if (x_ppem) glyph_pos->x_advance += (base+*(OffsetTo<Device>*)values++).get_delta (x_ppem) << 16; else values++; if (x_ppem) glyph_pos->x_advance += (base+*CastP<OffsetTo<Device> >(values++)).get_delta (x_ppem) << 16; else values++;
} }
if (format & yAdvDevice) { if (format & yAdvDevice) {
if (y_ppem) glyph_pos->y_advance += (base+*(OffsetTo<Device>*)values++).get_delta (y_ppem) << 16; else values++; if (y_ppem) glyph_pos->y_advance += (base+*CastP<OffsetTo<Device> >(values++)).get_delta (y_ppem) << 16; else values++;
} }
} }
private: private:
inline bool sanitize_value_devices (hb_sanitize_context_t *context, void *base, const Value *values) { inline bool sanitize_value_devices (hb_sanitize_context_t *context, void *base, Value *values) {
unsigned int format = *this; unsigned int format = *this;
if (format & xPlacement) values++; if (format & xPlacement) values++;
@ -142,10 +142,10 @@ struct ValueFormat : USHORT
if (format & xAdvance) values++; if (format & xAdvance) values++;
if (format & yAdvance) values++; if (format & yAdvance) values++;
if ((format & xPlaDevice) && !SANITIZE_WITH_BASE (base, *(OffsetTo<Device>*)values++)) return false; if ((format & xPlaDevice) && !CastP<OffsetTo<Device> > (values++)->sanitize (context, base)) return false;
if ((format & yPlaDevice) && !SANITIZE_WITH_BASE (base, *(OffsetTo<Device>*)values++)) return false; if ((format & yPlaDevice) && !CastP<OffsetTo<Device> > (values++)->sanitize (context, base)) return false;
if ((format & xAdvDevice) && !SANITIZE_WITH_BASE (base, *(OffsetTo<Device>*)values++)) return false; if ((format & xAdvDevice) && !CastP<OffsetTo<Device> > (values++)->sanitize (context, base)) return false;
if ((format & yAdvDevice) && !SANITIZE_WITH_BASE (base, *(OffsetTo<Device>*)values++)) return false; if ((format & yAdvDevice) && !CastP<OffsetTo<Device> > (values++)->sanitize (context, base)) return false;
return true; return true;
} }
@ -157,13 +157,13 @@ struct ValueFormat : USHORT
return (format & devices) != 0; return (format & devices) != 0;
} }
inline bool sanitize_value (hb_sanitize_context_t *context, void *base, const Value *values) { inline bool sanitize_value (hb_sanitize_context_t *context, void *base, Value *values) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return context->check_range (values, get_size ()) return context->check_range (values, get_size ())
&& (!has_device () || sanitize_value_devices (context, base, values)); && (!has_device () || sanitize_value_devices (context, base, values));
} }
inline bool sanitize_values (hb_sanitize_context_t *context, void *base, const Value *values, unsigned int count) { inline bool sanitize_values (hb_sanitize_context_t *context, void *base, Value *values, unsigned int count) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
unsigned int len = get_len (); unsigned int len = get_len ();
@ -181,7 +181,7 @@ struct ValueFormat : USHORT
} }
/* Just sanitize referenced Device tables. Doesn't check the values themselves. */ /* Just sanitize referenced Device tables. Doesn't check the values themselves. */
inline bool sanitize_values_stride_unsafe (hb_sanitize_context_t *context, void *base, const Value *values, unsigned int count, unsigned int stride) { inline bool sanitize_values_stride_unsafe (hb_sanitize_context_t *context, void *base, Value *values, unsigned int count, unsigned int stride) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!has_device ()) return true; if (!has_device ()) return true;
@ -275,8 +275,8 @@ struct AnchorFormat3
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_SELF () return SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (this, xDeviceTable) && xDeviceTable.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, yDeviceTable); && yDeviceTable.sanitize (context, this);
} }
private: private:
@ -343,7 +343,7 @@ struct AnchorMatrix
unsigned int count = rows * cols; unsigned int count = rows * cols;
if (!context->check_array (matrix, matrix[0].get_size (), count)) return false; if (!context->check_array (matrix, matrix[0].get_size (), count)) return false;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
if (!SANITIZE_WITH_BASE (this, matrix[i])) return false; if (!matrix[i].sanitize (context, this)) return false;
return true; return true;
} }
@ -365,7 +365,7 @@ struct MarkRecord
inline bool sanitize (hb_sanitize_context_t *context, void *base) { inline bool sanitize (hb_sanitize_context_t *context, void *base) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_SELF () return SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (base, markAnchor); && markAnchor.sanitize (context, base);
} }
private: private:
@ -408,7 +408,7 @@ struct MarkArray
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, markRecord); return markRecord.sanitize (context, this);
} }
private: private:
@ -441,7 +441,7 @@ struct SinglePosFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_SELF () return SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (this, coverage) && coverage.sanitize (context, this)
&& valueFormat.sanitize_value (context, CharP(this), values); && valueFormat.sanitize_value (context, CharP(this), values);
} }
@ -484,7 +484,7 @@ struct SinglePosFormat2
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_SELF () return SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (this, coverage) && coverage.sanitize (context, this)
&& valueFormat.sanitize_values (context, CharP(this), values, valueCount); && valueFormat.sanitize_values (context, CharP(this), values, valueCount);
} }
@ -623,7 +623,7 @@ struct PairPosFormat1
unsigned int len2 = valueFormat2.get_len (); unsigned int len2 = valueFormat2.get_len ();
if (!(SANITIZE_SELF () if (!(SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (this, coverage) && coverage.sanitize (context, this)
&& likely (pairSet.sanitize (context, CharP(this), len1 + len2)))) return false; && likely (pairSet.sanitize (context, CharP(this), len1 + len2)))) return false;
if (!(valueFormat1.has_device () || valueFormat2.has_device ())) return true; if (!(valueFormat1.has_device () || valueFormat2.has_device ())) return true;
@ -632,10 +632,10 @@ struct PairPosFormat1
unsigned int count1 = pairSet.len; unsigned int count1 = pairSet.len;
for (unsigned int i = 0; i < count1; i++) for (unsigned int i = 0; i < count1; i++)
{ {
const PairSet &pair_set = this+pairSet[i]; PairSet &pair_set = const_cast<PairSet &> (this+pairSet[i]); /* XXX clean this up */
unsigned int count2 = pair_set.len; unsigned int count2 = pair_set.len;
const PairValueRecord *record = pair_set.array; PairValueRecord *record = pair_set.array;
if (!(valueFormat1.sanitize_values_stride_unsafe (context, CharP(this), &record->values[0], count2, stride) && if (!(valueFormat1.sanitize_values_stride_unsafe (context, CharP(this), &record->values[0], count2, stride) &&
valueFormat2.sanitize_values_stride_unsafe (context, CharP(this), &record->values[len1], count2, stride))) valueFormat2.sanitize_values_stride_unsafe (context, CharP(this), &record->values[len1], count2, stride)))
return false; return false;
@ -708,9 +708,9 @@ struct PairPosFormat2
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!(SANITIZE_SELF () if (!(SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (this, coverage) && coverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, classDef1) && classDef1.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, classDef2))) return false; && classDef2.sanitize (context, this))) return false;
unsigned int len1 = valueFormat1.get_len (); unsigned int len1 = valueFormat1.get_len ();
unsigned int len2 = valueFormat2.get_len (); unsigned int len2 = valueFormat2.get_len ();
@ -791,8 +791,8 @@ struct EntryExitRecord
inline bool sanitize (hb_sanitize_context_t *context, void *base) { inline bool sanitize (hb_sanitize_context_t *context, void *base) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (base, entryAnchor) return entryAnchor.sanitize (context, base)
&& SANITIZE_WITH_BASE (base, exitAnchor); && exitAnchor.sanitize (context, base);
} }
OffsetTo<Anchor> OffsetTo<Anchor>
@ -988,8 +988,8 @@ struct CursivePosFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, coverage) return coverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, entryExitRecord); && entryExitRecord.sanitize (context, this);
} }
private: private:
@ -1077,9 +1077,9 @@ struct MarkBasePosFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_SELF () return SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (this, markCoverage) && markCoverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, baseCoverage) && baseCoverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, markArray) && markArray.sanitize (context, this)
&& likely (baseArray.sanitize (context, CharP(this), (unsigned int) classCount)); && likely (baseArray.sanitize (context, CharP(this), (unsigned int) classCount));
} }
@ -1201,9 +1201,9 @@ struct MarkLigPosFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_SELF () return SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (this, markCoverage) && markCoverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, ligatureCoverage) && ligatureCoverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, markArray) && markArray.sanitize (context, this)
&& likely (ligatureArray.sanitize (context, CharP(this), (unsigned int) classCount)); && likely (ligatureArray.sanitize (context, CharP(this), (unsigned int) classCount));
} }
@ -1304,9 +1304,9 @@ struct MarkMarkPosFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_SELF () return SANITIZE_SELF ()
&& SANITIZE_WITH_BASE (this, mark1Coverage) && mark1Coverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, mark2Coverage) && mark2Coverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, mark1Array) && mark1Array.sanitize (context, this)
&& likely (mark2Array.sanitize (context, CharP(this), (unsigned int) classCount)); && likely (mark2Array.sanitize (context, CharP(this), (unsigned int) classCount));
} }
@ -1548,7 +1548,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 SANITIZE_WITH_BASE (this, list); return list.sanitize (context, this);
} }
}; };
@ -1576,7 +1576,7 @@ struct GPOS : GSUBGPOS
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (unlikely (!GSUBGPOS::sanitize (context))) return false; if (unlikely (!GSUBGPOS::sanitize (context))) return false;
OffsetTo<PosLookupList> &list = CastR<OffsetTo<PosLookupList> > (lookupList); OffsetTo<PosLookupList> &list = CastR<OffsetTo<PosLookupList> > (lookupList);
return SANITIZE_WITH_BASE (this, list); return list.sanitize (context, this);
} }
}; };
ASSERT_SIZE (GPOS, 10); ASSERT_SIZE (GPOS, 10);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2007,2008,2009 Red Hat, Inc. * Copyright (C) 2007,2008,2009,2010 Red Hat, Inc.
* *
* This is part of HarfBuzz, a text shaping library. * This is part of HarfBuzz, a text shaping library.
* *
@ -60,7 +60,7 @@ struct SingleSubstFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, coverage) return coverage.sanitize (context, this)
&& SANITIZE (deltaGlyphID); && SANITIZE (deltaGlyphID);
} }
@ -103,7 +103,7 @@ struct SingleSubstFormat2
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, coverage) return coverage.sanitize (context, this)
&& SANITIZE (substitute); && SANITIZE (substitute);
} }
@ -214,8 +214,8 @@ struct MultipleSubstFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, coverage) return coverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, sequence); && sequence.sanitize (context, this);
} }
private: private:
@ -310,8 +310,8 @@ struct AlternateSubstFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, coverage) return coverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, alternateSet); && alternateSet.sanitize (context, this);
} }
private: private:
@ -463,7 +463,7 @@ struct LigatureSet
public: public:
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, ligature); return ligature.sanitize (context, this);
} }
private: private:
@ -495,8 +495,8 @@ struct LigatureSubstFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, coverage) return coverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, ligatureSet); && ligatureSet.sanitize (context, this);
} }
private: private:
@ -626,11 +626,11 @@ struct ReverseChainSingleSubstFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!(SANITIZE_WITH_BASE (this, coverage) if (!(coverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, backtrack))) && backtrack.sanitize (context, this)))
return false; return false;
OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack); OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
if (!SANITIZE_WITH_BASE (this, lookahead)) if (!lookahead.sanitize (context, this))
return false; return false;
ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead); ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
return SANITIZE (substitute); return SANITIZE (substitute);
@ -860,7 +860,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 SANITIZE_WITH_BASE (this, list); return list.sanitize (context, this);
} }
}; };
@ -884,12 +884,11 @@ struct GSUB : GSUBGPOS
hb_mask_t mask) const hb_mask_t mask) const
{ return get_lookup (lookup_index).apply_string (layout, buffer, mask); } { return get_lookup (lookup_index).apply_string (layout, buffer, mask); }
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (unlikely (!GSUBGPOS::sanitize (context))) return false; if (unlikely (!GSUBGPOS::sanitize (context))) return false;
OffsetTo<SubstLookupList> &list = CastR<OffsetTo<SubstLookupList> > (lookupList); OffsetTo<SubstLookupList> &list = CastR<OffsetTo<SubstLookupList> > (lookupList);
return SANITIZE_WITH_BASE (this, list); return list.sanitize (context, this);
} }
}; };
ASSERT_SIZE (GSUB, 10); ASSERT_SIZE (GSUB, 10);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2007,2008,2009 Red Hat, Inc. * Copyright (C) 2007,2008,2009,2010 Red Hat, Inc.
* *
* This is part of HarfBuzz, a text shaping library. * This is part of HarfBuzz, a text shaping library.
* *
@ -323,7 +323,7 @@ struct RuleSet
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, rule); return rule.sanitize (context, this);
} }
private: private:
@ -355,8 +355,8 @@ struct ContextFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, coverage) return coverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, ruleSet); && ruleSet.sanitize (context, this);
} }
private: private:
@ -398,9 +398,9 @@ struct ContextFormat2
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, coverage) return coverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, classDef) && classDef.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, ruleSet); && ruleSet.sanitize (context, this);
} }
private: private:
@ -447,7 +447,7 @@ struct ContextFormat3
unsigned int count = glyphCount; unsigned int count = glyphCount;
if (!context->check_array (coverage, OffsetTo<Coverage>::get_size (), count)) return false; if (!context->check_array (coverage, OffsetTo<Coverage>::get_size (), count)) return false;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
if (!SANITIZE_WITH_BASE (this, coverage[i])) return false; if (!coverage[i].sanitize (context, this)) return false;
LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, OffsetTo<Coverage>::get_size () * count); LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, OffsetTo<Coverage>::get_size () * count);
return context->check_array (lookupRecord, LookupRecord::get_size (), lookupCount); return context->check_array (lookupRecord, LookupRecord::get_size (), lookupCount);
} }
@ -609,7 +609,7 @@ struct ChainRuleSet
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, rule); return rule.sanitize (context, this);
} }
private: private:
@ -641,8 +641,8 @@ struct ChainContextFormat1
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, coverage) return coverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, ruleSet); && ruleSet.sanitize (context, this);
} }
private: private:
@ -688,11 +688,11 @@ struct ChainContextFormat2
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_WITH_BASE (this, coverage) return coverage.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, backtrackClassDef) && backtrackClassDef.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, inputClassDef) && inputClassDef.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, lookaheadClassDef) && lookaheadClassDef.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, ruleSet); && ruleSet.sanitize (context, this);
} }
private: private:
@ -750,11 +750,11 @@ struct ChainContextFormat3
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE_WITH_BASE (this, backtrack)) return false; if (!backtrack.sanitize (context, this)) return false;
OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
if (!SANITIZE_WITH_BASE (this, input)) return false; if (!input.sanitize (context, this)) return false;
OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input); OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
if (!SANITIZE_WITH_BASE (this, lookahead)) return false; if (!lookahead.sanitize (context, this)) return false;
ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
return SANITIZE (lookup); return SANITIZE (lookup);
} }
@ -914,9 +914,9 @@ struct GSUBGPOS
inline bool sanitize (hb_sanitize_context_t *context) { inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE (version) && likely (version.major == 1) return SANITIZE (version) && likely (version.major == 1)
&& SANITIZE_WITH_BASE (this, scriptList) && scriptList.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, featureList) && featureList.sanitize (context, this)
&& SANITIZE_WITH_BASE (this, lookupList); && lookupList.sanitize (context, this);
} }
protected: protected: