Remove the last of SANITIZE macros: SANITIZE_SELF
diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index b58e26b..cf75df9 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -51,7 +51,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ();
+ return context->check_struct (this);
}
Tag tag; /* 4-byte identifier. */
@@ -100,7 +100,7 @@
public:
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ()
+ return context->check_struct (this)
&& context->check_array (tableDir, TableDirectory::get_size (), numTables);
}
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 82c23c6..82242e9 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -202,7 +202,6 @@
{
bool overflows = len >= ((unsigned int) -1) / record_size;
-
if (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE)
fprintf (stderr, "SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s\n", \
base,
@@ -214,6 +213,12 @@
return likely (!overflows && this->check_range (base, record_size * len));
}
+ template <typename Type>
+ inline bool check_struct (const Type *obj) const
+ {
+ return likely (this->check_range (obj, sizeof (*obj)));
+ }
+
inline bool can_edit (const char *base HB_UNUSED, unsigned int len HB_UNUSED)
{
this->edit_count++;
@@ -238,8 +243,6 @@
};
-#define SANITIZE_SELF() likely(context->check_range (this, sizeof (*this)))
-
/* Template to sanitize an object. */
template <typename Type>
@@ -352,7 +355,7 @@
inline bool operator != (const IntType<Type> &o) const { return v != o.v; }
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ();
+ return context->check_struct (this);
}
private: BEInt<Type, sizeof (Type)> v;
};
@@ -414,7 +417,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ();
+ return context->check_struct (this);
}
USHORT major;
@@ -441,7 +444,7 @@
inline bool sanitize (hb_sanitize_context_t *context, void *base) {
TRACE_SANITIZE ();
- if (!SANITIZE_SELF ()) return false;
+ if (!context->check_struct (this)) return false;
unsigned int offset = *this;
if (unlikely (!offset)) return true;
Type &obj = StructAtOffset<Type> (*CharP(base), offset);
@@ -450,7 +453,7 @@
template <typename T>
inline bool sanitize (hb_sanitize_context_t *context, void *base, T user_data) {
TRACE_SANITIZE ();
- if (!SANITIZE_SELF ()) return false;
+ if (!context->check_struct (this)) return false;
unsigned int offset = *this;
if (unlikely (!offset)) return true;
Type &obj = StructAtOffset<Type> (*CharP(base), offset);
@@ -547,7 +550,7 @@
private:
inline bool sanitize_shallow (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF()
+ return context->check_struct (this)
&& context->check_array (this, Type::get_size (), len);
}
@@ -615,7 +618,7 @@
{ return len.get_size () + (len ? len - 1 : 0) * Type::get_size (); }
inline bool sanitize_shallow (hb_sanitize_context_t *context) {
- return SANITIZE_SELF()
+ return context->check_struct (this)
&& context->check_array (this, Type::get_size (), len);
}
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 0ff3dd6..09a6930 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -55,7 +55,7 @@
inline bool sanitize (hb_sanitize_context_t *context, void *base) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ()
+ return context->check_struct (this)
&& offset.sanitize (context, base);
}
@@ -166,7 +166,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ()
+ return context->check_struct (this)
&& featureIndex.sanitize (context);
}
@@ -235,7 +235,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ()
+ return context->check_struct (this)
&& lookupIndex.sanitize (context);
}
@@ -287,7 +287,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
/* Real sanitize of the subtables is done by GSUB/GPOS/... */
- if (!(SANITIZE_SELF ()
+ if (!(context->check_struct (this)
&& likely (subTable.sanitize (context)))) return false;
if (unlikely (lookupFlag & LookupFlag::UseMarkFilteringSet))
{
@@ -363,7 +363,7 @@
public:
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ();
+ return context->check_struct (this);
}
private:
@@ -457,7 +457,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ()
+ return context->check_struct (this)
&& classValue.sanitize (context);
}
@@ -485,7 +485,7 @@
public:
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ();
+ return context->check_struct (this);
}
private:
@@ -598,7 +598,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF()
+ return context->check_struct (this)
&& context->check_range (this, this->get_size ());
}
diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh
index 76b3ffc..652561c 100644
--- a/src/hb-ot-layout-gdef-private.hh
+++ b/src/hb-ot-layout-gdef-private.hh
@@ -100,7 +100,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ();
+ return context->check_struct (this);
}
private:
@@ -126,7 +126,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ();
+ return context->check_struct (this);
}
private:
@@ -148,7 +148,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ()
+ return context->check_struct (this)
&& deviceTable.sanitize (context, this);
}
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 95d9353..60ee17e 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -220,7 +220,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ();
+ return context->check_struct (this);
}
private:
@@ -251,7 +251,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ();
+ return context->check_struct (this);
}
private:
@@ -282,7 +282,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ()
+ return context->check_struct (this)
&& xDeviceTable.sanitize (context, this)
&& yDeviceTable.sanitize (context, this);
}
@@ -346,7 +346,7 @@
inline bool sanitize (hb_sanitize_context_t *context, unsigned int cols) {
TRACE_SANITIZE ();
- if (!SANITIZE_SELF ()) return false;
+ if (!context->check_struct (this)) return false;
if (unlikely (cols >= ((unsigned int) -1) / rows)) return false;
unsigned int count = rows * cols;
if (!context->check_array (matrix, matrix[0].get_size (), count)) return false;
@@ -372,7 +372,7 @@
inline bool sanitize (hb_sanitize_context_t *context, void *base) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ()
+ return context->check_struct (this)
&& markAnchor.sanitize (context, base);
}
@@ -448,7 +448,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ()
+ return context->check_struct (this)
&& coverage.sanitize (context, this)
&& valueFormat.sanitize_value (context, CharP(this), values);
}
@@ -491,7 +491,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ()
+ return context->check_struct (this)
&& coverage.sanitize (context, this)
&& valueFormat.sanitize_values (context, CharP(this), values, valueCount);
}
@@ -563,7 +563,7 @@
/* Note: Doesn't sanitize the Device entries in the ValueRecord */
inline bool sanitize (hb_sanitize_context_t *context, unsigned int format_len) {
TRACE_SANITIZE ();
- if (!SANITIZE_SELF ()) return false;
+ if (!context->check_struct (this)) return false;
unsigned int count = (1 + format_len) * len;
return context->check_array (array, USHORT::get_size (), count);
}
@@ -630,7 +630,7 @@
unsigned int len1 = valueFormat1.get_len ();
unsigned int len2 = valueFormat2.get_len ();
- if (!(SANITIZE_SELF ()
+ if (!(context->check_struct (this)
&& coverage.sanitize (context, this)
&& likely (pairSet.sanitize (context, CharP(this), len1 + len2)))) return false;
@@ -715,7 +715,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- if (!(SANITIZE_SELF ()
+ if (!(context->check_struct (this)
&& coverage.sanitize (context, this)
&& classDef1.sanitize (context, this)
&& classDef2.sanitize (context, this))) return false;
@@ -1084,7 +1084,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ()
+ return context->check_struct (this)
&& markCoverage.sanitize (context, this)
&& baseCoverage.sanitize (context, this)
&& markArray.sanitize (context, this)
@@ -1208,7 +1208,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ()
+ return context->check_struct (this)
&& markCoverage.sanitize (context, this)
&& ligatureCoverage.sanitize (context, this)
&& markArray.sanitize (context, this)
@@ -1311,7 +1311,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ()
+ return context->check_struct (this)
&& mark1Coverage.sanitize (context, this)
&& mark2Coverage.sanitize (context, this)
&& mark1Array.sanitize (context, this)
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 9f2ab4a..7777b9c 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -176,7 +176,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ();
+ return context->check_struct (this);
}
USHORT sequenceIndex; /* Index into current glyph
@@ -443,7 +443,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- if (!SANITIZE_SELF ()) return false;
+ if (!context->check_struct (this)) return false;
unsigned int count = glyphCount;
if (!context->check_array (coverage, OffsetTo<Coverage>::get_size (), count)) return false;
for (unsigned int i = 0; i < count; i++)
@@ -824,7 +824,7 @@
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return SANITIZE_SELF ();
+ return context->check_struct (this);
}
private: