From: Behdad Esfahbod Date: Thu, 6 May 2010 00:15:14 +0000 (-0400) Subject: Remove SANITIZE_ARRAY X-Git-Tag: submit/2.0alpha-wayland/20121130.004132~9^2~720 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1cd1e117d060d38e314618b627d7663cb01ed584;p=profile%2Fivi%2Forg.tizen.video-player.git Remove SANITIZE_ARRAY --- diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh index 5684383..1c1a8d6 100644 --- a/src/hb-open-file-private.hh +++ b/src/hb-open-file-private.hh @@ -101,7 +101,7 @@ typedef struct OffsetTable inline bool sanitize (hb_sanitize_context_t *context) { TRACE_SANITIZE (); return SANITIZE_SELF () - && SANITIZE_ARRAY (tableDir, TableDirectory::get_size (), numTables); + && context->check_array (tableDir, TableDirectory::get_size (), numTables); } private: diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 8e90133..ea95c07 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -181,24 +181,24 @@ struct hb_sanitize_context_t this->start = this->end = NULL; } - inline bool check (const char *base, unsigned int len) const + inline bool check (const void *base, unsigned int len) const { bool ret = this->start <= base && base <= this->end && - (unsigned int) (this->end - base) >= len; + (unsigned int) (this->end - CharP(base)) >= len; if (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE) \ fprintf (stderr, "SANITIZE(%p) %-*d-> check [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \ base, this->debug_depth, this->debug_depth, - base, base+len, len, + base, CharP(base)+len, len, this->start, this->end, ret ? "pass" : "FAIL"); return likely (ret); } - inline bool check_array (const char *base, unsigned int record_size, unsigned int len) const + inline bool check_array (const void *base, unsigned int record_size, unsigned int len) const { bool overflows = len >= ((unsigned int) -1) / record_size; @@ -207,7 +207,7 @@ struct hb_sanitize_context_t fprintf (stderr, "SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s\n", \ base, this->debug_depth, this->debug_depth, - base, base + (record_size * len), record_size, len, (unsigned long) record_size * len, + base, CharP(base) + (record_size * len), record_size, len, (unsigned long) record_size * len, this->start, this->end, !overflows ? "does not overflow" : "OVERFLOWS FAIL"); @@ -246,8 +246,6 @@ struct hb_sanitize_context_t #define SANITIZE_MEM(B,L) likely (context->check (CharP(B), (L))) -#define SANITIZE_ARRAY(A,S,L) likely (context->check_array (CharP(A), S, L)) - /* Template to sanitize an object. */ template @@ -556,7 +554,7 @@ struct GenericArrayOf inline bool sanitize_shallow (hb_sanitize_context_t *context) { TRACE_SANITIZE (); return SANITIZE_SELF() - && SANITIZE_ARRAY (this, Type::get_size (), len); + && context->check_array (this, Type::get_size (), len); } public: @@ -624,7 +622,7 @@ struct HeadlessArrayOf inline bool sanitize_shallow (hb_sanitize_context_t *context) { return SANITIZE_SELF() - && SANITIZE_ARRAY (this, Type::get_size (), len); + && context->check_array (this, Type::get_size (), len); } inline bool sanitize (hb_sanitize_context_t *context) { diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh index 145fc04..98cc371 100644 --- a/src/hb-ot-layout-gpos-private.hh +++ b/src/hb-ot-layout-gpos-private.hh @@ -167,7 +167,7 @@ struct ValueFormat : USHORT TRACE_SANITIZE (); unsigned int len = get_len (); - if (!SANITIZE_ARRAY (values, get_size (), count)) return false; + if (!context->check_array (values, get_size (), count)) return false; if (!has_device ()) return true; @@ -341,7 +341,7 @@ struct AnchorMatrix if (!SANITIZE_SELF ()) return false; if (unlikely (cols >= ((unsigned int) -1) / rows)) return false; unsigned int count = rows * cols; - if (!SANITIZE_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++) if (!SANITIZE_WITH_BASE (this, matrix[i])) return false; return true; @@ -557,7 +557,7 @@ struct PairSet TRACE_SANITIZE (); if (!SANITIZE_SELF ()) return false; unsigned int count = (1 + format_len) * len; - return SANITIZE_ARRAY (array, USHORT::get_size (), count); + return context->check_array (array, USHORT::get_size (), count); } private: @@ -717,7 +717,7 @@ struct PairPosFormat2 unsigned int stride = len1 + len2; unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size (); unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count; - return SANITIZE_ARRAY (values, record_size, count) && + return context->check_array (values, record_size, count) && valueFormat1.sanitize_values_stride_unsafe (context, CharP(this), &values[0], count, stride) && valueFormat2.sanitize_values_stride_unsafe (context, CharP(this), &values[len1], count, stride); } diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index 6ed1bf7..bb10bdf 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -445,11 +445,11 @@ struct ContextFormat3 TRACE_SANITIZE (); if (!SANITIZE_SELF ()) return false; unsigned int count = glyphCount; - if (!SANITIZE_ARRAY (coverage, OffsetTo::get_size (), count)) return false; + if (!context->check_array (coverage, OffsetTo::get_size (), count)) return false; for (unsigned int i = 0; i < count; i++) if (!SANITIZE_WITH_BASE (this, coverage[i])) return false; LookupRecord *lookupRecord = &StructAtOffset (coverage, OffsetTo::get_size () * count); - return SANITIZE_ARRAY (lookupRecord, LookupRecord::get_size (), lookupCount); + return context->check_array (lookupRecord, LookupRecord::get_size (), lookupCount); } private: