[HB] Tag sanitize()
authorBehdad Esfahbod <behdad@behdad.org>
Tue, 4 Aug 2009 18:42:46 +0000 (14:42 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Mon, 2 Nov 2009 19:40:29 +0000 (14:40 -0500)
src/hb-open-types-private.hh
src/hb-ot-layout-common-private.hh

index 8e325d7..d923b88 100644 (file)
@@ -282,6 +282,14 @@ struct Tag : ULONG
   /* What the char* converters return is NOT nul-terminated.  Print using "%.4s" */
   inline operator const char* (void) const { return CONST_CHARP(this); }
   inline operator char* (void) { return CHARP(this); }
+
+  inline bool sanitize (SANITIZE_ARG_DEF) {
+    /* Note: Only accept ASCII-visible tags (mind DEL)
+     * This is one of the few times (only time?) we check
+     * for data integrity, as opposed o just boundary checks
+     */
+    return SANITIZE_SELF () && (((uint32_t) *this) & 0x80808080) == 0;
+  }
 };
 ASSERT_SIZE (Tag, 4);
 #define _NULL_TAG_INIT  {' ', ' ', ' ', ' '}
index 18b1909..1fbec02 100644 (file)
@@ -47,11 +47,7 @@ template <typename Type>
 struct Record
 {
   inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
-    /* Note: Only accept ASCII-visible tags (mind DEL)
-     * This is one of the few times (only time?) we check
-     * for data integrity, as opposed o just boundary checks
-     */
-    return (tag & 0x80808080) == 0 && offset.sanitize (SANITIZE_ARG, base);
+    return SANITIZE (tag) == 0 && SANITIZE_BASE (offset, base);
   }
 
   Tag          tag;            /* 4-byte Tag identifier */