[pango/harfbuzz-ng: 53/57] [HB] GDEF sanitize()



commit 7e7f9f5a7f6aef9bacd9782b943883e127aae49b
Author: Behdad Esfahbod <behdad behdad org>
Date:   Tue Aug 4 14:33:23 2009 -0400

    [HB] GDEF sanitize()

 pango/opentype/hb-ot-layout-gdef-private.hh     |   54 +++++++++++++++++++++++
 pango/opentype/hb-ot-layout-gpos-private.hh     |    2 +-
 pango/opentype/hb-ot-layout-gsub-private.hh     |    2 +-
 pango/opentype/hb-ot-layout-gsubgpos-private.hh |    2 +-
 4 files changed, 57 insertions(+), 3 deletions(-)
---
diff --git a/pango/opentype/hb-ot-layout-gdef-private.hh b/pango/opentype/hb-ot-layout-gdef-private.hh
index 97d124e..2a96a64 100644
--- a/pango/opentype/hb-ot-layout-gdef-private.hh
+++ b/pango/opentype/hb-ot-layout-gdef-private.hh
@@ -73,6 +73,10 @@ struct AttachList
     return true;
   }
 
+  inline bool sanitize (SANITIZE_ARG_DEF) {
+    return SANITIZE_THIS2 (coverage, attachPoint);
+  }
+
   private:
   OffsetTo<Coverage>
 		coverage;		/* Offset to Coverage table -- from
@@ -98,6 +102,10 @@ struct CaretValueFormat1
     return context->font->x_scale * coordinate / 0x10000;
   }
 
+  inline bool sanitize (SANITIZE_ARG_DEF) {
+    return SANITIZE_SELF ();
+  }
+
   private:
   USHORT	caretValueFormat;	/* Format identifier--format = 1 */
   SHORT		coordinate;		/* X or Y value, in design units */
@@ -114,6 +122,10 @@ struct CaretValueFormat2
     return /* TODO contour point */ 0;
   }
 
+  inline bool sanitize (SANITIZE_ARG_DEF) {
+    return SANITIZE_SELF ();
+  }
+
   private:
   USHORT	caretValueFormat;	/* Format identifier--format = 2 */
   USHORT	caretValuePoint;	/* Contour point index on glyph */
@@ -131,6 +143,10 @@ struct CaretValueFormat3
 	   ((this+deviceTable).get_delta (context->font->x_ppem) << 6);
   }
 
+  inline bool sanitize (SANITIZE_ARG_DEF) {
+    return SANITIZE_SELF () && SANITIZE_THIS (deviceTable);
+  }
+
   private:
   USHORT	caretValueFormat;	/* Format identifier--format = 3 */
   SHORT		coordinate;		/* X or Y value, in design units */
@@ -154,6 +170,16 @@ struct CaretValue
     }
   }
 
+  inline bool sanitize (SANITIZE_ARG_DEF) {
+    if (!SANITIZE (u.format)) return false;
+    switch (u.format) {
+    case 1: return u.format1->sanitize (SANITIZE_ARG);
+    case 2: return u.format2->sanitize (SANITIZE_ARG);
+    case 3: return u.format3->sanitize (SANITIZE_ARG);
+    default:return true;
+    }
+  }
+
   private:
   union {
   USHORT		format;		/* Format identifier */
@@ -179,6 +205,10 @@ struct LigGlyph
     *caret_count = carets.len;
   }
 
+  inline bool sanitize (SANITIZE_ARG_DEF) {
+    return SANITIZE (carets);
+  }
+
   private:
   OffsetArrayOf<CaretValue>
 		carets;			/* Offset rrray of CaretValue tables
@@ -205,6 +235,10 @@ struct LigCaretList
     return true;
   }
 
+  inline bool sanitize (SANITIZE_ARG_DEF) {
+    return SANITIZE_THIS2 (coverage, ligGlyph);
+  }
+
   private:
   OffsetTo<Coverage>
 		coverage;		/* Offset to Coverage table--from
@@ -221,6 +255,10 @@ struct MarkGlyphSetsFormat1
   inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const
   { return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; }
 
+  inline bool sanitize (SANITIZE_ARG_DEF) {
+    return SANITIZE_THIS (coverage);
+  }
+
   private:
   USHORT	format;			/* Format identifier--format = 1 */
   LongOffsetArrayOf<Coverage>
@@ -239,6 +277,14 @@ struct MarkGlyphSets
     }
   }
 
+  inline bool sanitize (SANITIZE_ARG_DEF) {
+    if (!SANITIZE (u.format)) return false;
+    switch (u.format) {
+    case 1: return u.format1->sanitize (SANITIZE_ARG);
+    default:return true;
+    }
+  }
+
   private:
   union {
   USHORT		format;		/* Format identifier */
@@ -291,6 +337,14 @@ struct GDEF
   inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const
   { return version >= 0x00010002 && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); }
 
+  bool sanitize (SANITIZE_ARG_DEF) {
+    if (!SANITIZE (version)) return false;
+    if (version.major != 1) return true;
+    return SANITIZE_THIS2 (glyphClassDef, attachList) &&
+	   SANITIZE_THIS2 (ligCaretList, markAttachClassDef) &&
+	   (version < 0x00010002 || SANITIZE_THIS (markGlyphSetsDef[0]));
+  }
+
   private:
   FixedVersion	version;		/* Version of the GDEF table--currently
 					 * 0x00010002 */
diff --git a/pango/opentype/hb-ot-layout-gpos-private.hh b/pango/opentype/hb-ot-layout-gpos-private.hh
index 5648160..c245e0f 100644
--- a/pango/opentype/hb-ot-layout-gpos-private.hh
+++ b/pango/opentype/hb-ot-layout-gpos-private.hh
@@ -1501,7 +1501,7 @@ struct GPOS : GSUBGPOS
 			       hb_ot_layout_feature_mask_t  mask) const
   { return get_lookup (lookup_index).apply_string (context, buffer, mask); }
 
-  inline bool sanitize (SANITIZE_ARG_DEF) {
+  bool sanitize (SANITIZE_ARG_DEF) {
     if (GSUBGPOS::sanitize (SANITIZE_ARG)) return false;
     OffsetTo<PosLookupList> &list = CAST(OffsetTo<PosLookupList>, lookupList, 0);
     return SANITIZE_THIS (list);
diff --git a/pango/opentype/hb-ot-layout-gsub-private.hh b/pango/opentype/hb-ot-layout-gsub-private.hh
index a8977ac..535d636 100644
--- a/pango/opentype/hb-ot-layout-gsub-private.hh
+++ b/pango/opentype/hb-ot-layout-gsub-private.hh
@@ -838,7 +838,7 @@ struct GSUB : GSUBGPOS
   { return get_lookup (lookup_index).apply_string (context, buffer, mask); }
 
 
-  inline bool sanitize (SANITIZE_ARG_DEF) {
+  bool sanitize (SANITIZE_ARG_DEF) {
     if (GSUBGPOS::sanitize (SANITIZE_ARG)) return false;
     OffsetTo<SubstLookupList> &list = CAST(OffsetTo<SubstLookupList>, lookupList, 0);
     return SANITIZE_THIS (list);
diff --git a/pango/opentype/hb-ot-layout-gsubgpos-private.hh b/pango/opentype/hb-ot-layout-gsubgpos-private.hh
index 4a1ab24..0682691 100644
--- a/pango/opentype/hb-ot-layout-gsubgpos-private.hh
+++ b/pango/opentype/hb-ot-layout-gsubgpos-private.hh
@@ -848,7 +848,7 @@ struct GSUBGPOS
   DEFINE_TAG_FIND_INTERFACE (Script,  script );	/* find_script_index (), get_script_by_tag (tag) */
   DEFINE_TAG_FIND_INTERFACE (Feature, feature);	/* find_feature_index(), get_feature_by_tag(tag) */
 
-  inline bool sanitize (SANITIZE_ARG_DEF) {
+  bool sanitize (SANITIZE_ARG_DEF) {
     if (!SANITIZE (version)) return false;
     if (version.major != 1) return true;
     return SANITIZE_THIS3 (scriptList, featureList, lookupList);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]