mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-25 17:01:17 +01:00
Revert "[sanitize] Add "fastpath" for ArrayOfOffset16To<> objects with max size"
This reverts commit 10f8556c73.
This was, unfortunately, wrong :(.
This commit is contained in:
1 parent
f2a3680fab
commit
7a85663c2b
5 files changed
+3
-52
No files matched your search
@@ -19,14 +19,11 @@ struct Ligature
|
||||
* in writing direction */
|
||||
public:
|
||||
DEFINE_SIZE_ARRAY (Types::size + 2, component);
|
||||
DEFINE_SIZE_MAX (Types::size + 2 + HB_MAX_CONTEXT_LENGTH * Types::HBGlyphID::static_size);
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (ligGlyph.sanitize (c) &&
|
||||
component.sanitize (c) &&
|
||||
component.lenP1 <= HB_MAX_CONTEXT_LENGTH);
|
||||
return_trace (ligGlyph.sanitize (c) && component.sanitize (c));
|
||||
}
|
||||
|
||||
bool intersects (const hb_set_t *glyphs) const
|
||||
|
||||
@@ -131,10 +131,6 @@ static inline Type& StructAfter(TObject &X)
|
||||
unsigned int get_size () const { return (size - (array).min_size + (array).get_size ()); } \
|
||||
DEFINE_SIZE_ARRAY(size, array)
|
||||
|
||||
#define DEFINE_SIZE_MAX(size) \
|
||||
DEFINE_INSTANCE_ASSERTION (sizeof (*this) <= (size)) \
|
||||
static constexpr unsigned max_size = (size)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -48,15 +48,6 @@ template <typename T>
|
||||
using hb_has_min_size = _hb_has_min_size<T, void>;
|
||||
#define hb_has_min_size(T) hb_has_min_size<T>::value
|
||||
|
||||
template <typename T, typename>
|
||||
struct _hb_has_max_size : hb_false_type {};
|
||||
template <typename T>
|
||||
struct _hb_has_max_size<T, hb_void_t<decltype (T::max_size)>>
|
||||
: hb_true_type {};
|
||||
template <typename T>
|
||||
using hb_has_max_size = _hb_has_max_size<T, void>;
|
||||
#define hb_has_max_size(T) hb_has_max_size<T>::value
|
||||
|
||||
template <typename T, typename>
|
||||
struct _hb_has_null_size : hb_false_type {};
|
||||
template <typename T>
|
||||
|
||||
@@ -312,8 +312,6 @@ struct _hb_has_null<Type, true>
|
||||
template <typename Type, typename OffsetType, bool has_null=true>
|
||||
struct OffsetTo : Offset<OffsetType, has_null>
|
||||
{
|
||||
using target_t = Type;
|
||||
|
||||
// Make sure Type is not unbounded; works only for types that are fully defined at OffsetTo time.
|
||||
static_assert (has_null == false ||
|
||||
(hb_has_null_size (Type) || !hb_has_min_size (Type)), "");
|
||||
@@ -714,29 +712,6 @@ struct ArrayOf
|
||||
return_trace (out);
|
||||
}
|
||||
|
||||
/* Special-case ArrayOf Offset16To structs with a maximum size. */
|
||||
template <typename T = Type,
|
||||
typename Base = void,
|
||||
hb_enable_if (hb_has_max_size (typename T::target_t) &&
|
||||
sizeof (T) == 2)>
|
||||
bool sanitize (hb_sanitize_context_t *c, const Base *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
|
||||
if (unlikely (!sanitize_shallow (c))) return_trace (false);
|
||||
|
||||
unsigned max_len = 65536 + Type::target_t::max_size;
|
||||
|
||||
if (unlikely (c->check_range_fast (base, max_len)))
|
||||
return_trace (true);
|
||||
|
||||
unsigned int count = len;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
if (unlikely (!c->dispatch (arrayZ[i], base)))
|
||||
return_trace (false);
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
template <typename ...Ts>
|
||||
bool sanitize (hb_sanitize_context_t *c, Ts&&... ds) const
|
||||
{
|
||||
|
||||
@@ -2014,9 +2014,7 @@ struct Rule
|
||||
lookupCount.sanitize (c) &&
|
||||
c->check_range (inputZ.arrayZ,
|
||||
inputZ.item_size * (inputCount ? inputCount - 1 : 0) +
|
||||
LookupRecord::static_size * lookupCount) &&
|
||||
inputCount <= HB_MAX_CONTEXT_LENGTH &&
|
||||
lookupCount <= HB_MAX_CONTEXT_LENGTH);
|
||||
LookupRecord::static_size * lookupCount));
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -2032,7 +2030,6 @@ struct Rule
|
||||
* design order */
|
||||
public:
|
||||
DEFINE_SIZE_ARRAY (4, inputZ);
|
||||
DEFINE_SIZE_MAX (4 + HB_MAX_CONTEXT_LENGTH * (Types::HBUINT::static_size + LookupRecord::static_size));
|
||||
};
|
||||
|
||||
template <typename Types>
|
||||
@@ -3095,11 +3092,7 @@ struct ChainRule
|
||||
const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
|
||||
if (!lookahead.sanitize (c)) return_trace (false);
|
||||
const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
|
||||
if (!lookup.sanitize (c)) return_trace (false);
|
||||
return_trace (backtrack.len <= HB_MAX_CONTEXT_LENGTH &&
|
||||
input.lenP1 <= HB_MAX_CONTEXT_LENGTH &&
|
||||
lookahead.len <= HB_MAX_CONTEXT_LENGTH &&
|
||||
lookup.len <= HB_MAX_CONTEXT_LENGTH);
|
||||
return_trace (lookup.sanitize (c));
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -3118,7 +3111,6 @@ struct ChainRule
|
||||
* design order) */
|
||||
public:
|
||||
DEFINE_SIZE_MIN (8);
|
||||
DEFINE_SIZE_MAX (8 + HB_MAX_CONTEXT_LENGTH * (3 * Types::HBUINT::static_size + LookupRecord::static_size));
|
||||
};
|
||||
|
||||
template <typename Types>
|
||||
|
||||
Reference in new issue
Block a user