Rename hb_array_t::in_range to hb_array_t::check_range

pull/2066/head
Ebrahim Byagowi 5 years ago committed by Behdad Esfahbod
parent 72d83a0280
commit d67ba649a3
  1. 2
      src/hb-array.hh
  2. 20
      src/hb-ot-glyf-table.hh
  3. 16
      src/hb-ot-var-gvar-table.hh

@ -199,7 +199,7 @@ struct hb_array_t : hb_iter_with_fallback_t<hb_array_t<Type>, Type&>
template <typename T, template <typename T,
unsigned P = sizeof (Type), unsigned P = sizeof (Type),
hb_enable_if (P == 1)> hb_enable_if (P == 1)>
bool in_range (const T *p, unsigned int size = T::static_size) const bool check_range (const T *p, unsigned int size = T::static_size) const
{ {
return arrayZ <= ((const char *) p) return arrayZ <= ((const char *) p)
&& ((const char *) p) <= arrayZ + length && ((const char *) p) <= arrayZ + length

@ -361,7 +361,7 @@ struct glyf
typedef const CompositeGlyphChain *__item_t__; typedef const CompositeGlyphChain *__item_t__;
composite_iter_t (hb_bytes_t glyph_, __item_t__ current_) : composite_iter_t (hb_bytes_t glyph_, __item_t__ current_) :
glyph (glyph_), current (current_) glyph (glyph_), current (current_)
{ if (!in_range (current)) current = nullptr; } { if (!check_range (current)) current = nullptr; }
composite_iter_t () : glyph (hb_bytes_t ()), current (nullptr) {} composite_iter_t () : glyph (hb_bytes_t ()), current (nullptr) {}
const CompositeGlyphChain &__item__ () const { return *current; } const CompositeGlyphChain &__item__ () const { return *current; }
@ -372,16 +372,16 @@ struct glyf
const CompositeGlyphChain *possible = &StructAfter<CompositeGlyphChain, const CompositeGlyphChain *possible = &StructAfter<CompositeGlyphChain,
CompositeGlyphChain> (*current); CompositeGlyphChain> (*current);
if (!in_range (possible)) { current = nullptr; return; } if (!check_range (possible)) { current = nullptr; return; }
current = possible; current = possible;
} }
bool operator != (const composite_iter_t& o) const bool operator != (const composite_iter_t& o) const
{ return glyph != o.glyph || current != o.current; } { return glyph != o.glyph || current != o.current; }
bool in_range (const CompositeGlyphChain *composite) const bool check_range (const CompositeGlyphChain *composite) const
{ {
return glyph.in_range (composite, CompositeGlyphChain::min_size) return glyph.check_range (composite, CompositeGlyphChain::min_size)
&& glyph.in_range (composite, composite->get_size ()); && glyph.check_range (composite, composite->get_size ());
} }
private: private:
@ -545,7 +545,7 @@ struct glyf
uint8_t flag = points_[i].flag; uint8_t flag = points_[i].flag;
if (coord_setter.is_short (flag)) if (coord_setter.is_short (flag))
{ {
if (unlikely (!bytes.in_range (p))) return false; if (unlikely (!bytes.check_range (p))) return false;
if (coord_setter.is_same (flag)) if (coord_setter.is_same (flag))
v += *p++; v += *p++;
else else
@ -555,7 +555,7 @@ struct glyf
{ {
if (!coord_setter.is_same (flag)) if (!coord_setter.is_same (flag))
{ {
if (unlikely (!bytes.in_range ((const HBUINT16 *) p))) return false; if (unlikely (!bytes.check_range ((const HBUINT16 *) p))) return false;
v += *(const HBINT16 *) p; v += *(const HBINT16 *) p;
p += HBINT16::static_size; p += HBINT16::static_size;
} }
@ -571,7 +571,7 @@ struct glyf
{ {
const HBUINT16 *endPtsOfContours = &StructAfter<HBUINT16> (header); const HBUINT16 *endPtsOfContours = &StructAfter<HBUINT16> (header);
int num_contours = header.numberOfContours; int num_contours = header.numberOfContours;
if (unlikely (!bytes.in_range (&endPtsOfContours[num_contours + 1]))) return false; if (unlikely (!bytes.check_range (&endPtsOfContours[num_contours + 1]))) return false;
unsigned int num_points = endPtsOfContours[num_contours - 1] + 1; unsigned int num_points = endPtsOfContours[num_contours - 1] + 1;
points_.resize (num_points + PHANTOM_COUNT); points_.resize (num_points + PHANTOM_COUNT);
@ -591,12 +591,12 @@ struct glyf
/* Read flags */ /* Read flags */
for (unsigned int i = 0; i < num_points; i++) for (unsigned int i = 0; i < num_points; i++)
{ {
if (unlikely (!bytes.in_range (p))) return false; if (unlikely (!bytes.check_range (p))) return false;
uint8_t flag = *p++; uint8_t flag = *p++;
points_[i].flag = flag; points_[i].flag = flag;
if (flag & FLAG_REPEAT) if (flag & FLAG_REPEAT)
{ {
if (unlikely (!bytes.in_range (p))) return false; if (unlikely (!bytes.check_range (p))) return false;
unsigned int repeat_count = *p++; unsigned int repeat_count = *p++;
while ((repeat_count-- > 0) && (++i < num_points)) while ((repeat_count-- > 0) && (++i < num_points))
points_[i].flag = flag; points_[i].flag = flag;

@ -283,12 +283,12 @@ struct GlyphVarData
POINT_RUN_COUNT_MASK = 0x7F POINT_RUN_COUNT_MASK = 0x7F
}; };
if (unlikely (!bytes.in_range (p))) return false; if (unlikely (!bytes.check_range (p))) return false;
uint16_t count = *p++; uint16_t count = *p++;
if (count & POINTS_ARE_WORDS) if (count & POINTS_ARE_WORDS)
{ {
if (unlikely (!bytes.in_range (p))) return false; if (unlikely (!bytes.check_range (p))) return false;
count = ((count & POINT_RUN_COUNT_MASK) << 8) | *p++; count = ((count & POINT_RUN_COUNT_MASK) << 8) | *p++;
} }
points.resize (count); points.resize (count);
@ -297,7 +297,7 @@ struct GlyphVarData
uint16_t i = 0; uint16_t i = 0;
while (i < count) while (i < count)
{ {
if (unlikely (!bytes.in_range (p))) return false; if (unlikely (!bytes.check_range (p))) return false;
uint16_t j; uint16_t j;
uint8_t control = *p++; uint8_t control = *p++;
uint16_t run_count = (control & POINT_RUN_COUNT_MASK) + 1; uint16_t run_count = (control & POINT_RUN_COUNT_MASK) + 1;
@ -305,7 +305,7 @@ struct GlyphVarData
{ {
for (j = 0; j < run_count && i < count; j++, i++) for (j = 0; j < run_count && i < count; j++, i++)
{ {
if (unlikely (!bytes.in_range ((const HBUINT16 *) p))) if (unlikely (!bytes.check_range ((const HBUINT16 *) p)))
return false; return false;
n += *(const HBUINT16 *)p; n += *(const HBUINT16 *)p;
points[i] = n; points[i] = n;
@ -316,7 +316,7 @@ struct GlyphVarData
{ {
for (j = 0; j < run_count && i < count; j++, i++) for (j = 0; j < run_count && i < count; j++, i++)
{ {
if (unlikely (!bytes.in_range (p))) return false; if (unlikely (!bytes.check_range (p))) return false;
n += *p++; n += *p++;
points[i] = n; points[i] = n;
} }
@ -341,7 +341,7 @@ struct GlyphVarData
unsigned int count = deltas.length; unsigned int count = deltas.length;
while (i < count) while (i < count)
{ {
if (unlikely (!bytes.in_range (p))) return false; if (unlikely (!bytes.check_range (p))) return false;
uint8_t control = *p++; uint8_t control = *p++;
unsigned int run_count = (control & DELTA_RUN_COUNT_MASK) + 1; unsigned int run_count = (control & DELTA_RUN_COUNT_MASK) + 1;
unsigned int j; unsigned int j;
@ -351,7 +351,7 @@ struct GlyphVarData
else if (control & DELTAS_ARE_WORDS) else if (control & DELTAS_ARE_WORDS)
for (j = 0; j < run_count && i < count; j++, i++) for (j = 0; j < run_count && i < count; j++, i++)
{ {
if (unlikely (!bytes.in_range ((const HBUINT16 *) p))) if (unlikely (!bytes.check_range ((const HBUINT16 *) p)))
return false; return false;
deltas[i] = *(const HBINT16 *) p; deltas[i] = *(const HBINT16 *) p;
p += HBUINT16::static_size; p += HBUINT16::static_size;
@ -359,7 +359,7 @@ struct GlyphVarData
else else
for (j = 0; j < run_count && i < count; j++, i++) for (j = 0; j < run_count && i < count; j++, i++)
{ {
if (unlikely (!bytes.in_range (p))) if (unlikely (!bytes.check_range (p)))
return false; return false;
deltas[i] = *(const HBINT8 *) p++; deltas[i] = *(const HBINT8 *) p++;
} }

Loading…
Cancel
Save