Move try_set to sanitize context
This commit is contained in:
parent
500737e8e1
commit
51f563579b
|
@ -266,6 +266,15 @@ struct hb_sanitize_context_t
|
||||||
return TRACE_RETURN (this->writable);
|
return TRACE_RETURN (this->writable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Type, typename ValueType>
|
||||||
|
inline bool try_set (Type *obj, const ValueType &v) {
|
||||||
|
if (this->may_edit (obj, obj->static_size)) {
|
||||||
|
obj->set (v);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mutable unsigned int debug_depth;
|
mutable unsigned int debug_depth;
|
||||||
const char *start, *end;
|
const char *start, *end;
|
||||||
bool writable;
|
bool writable;
|
||||||
|
@ -722,20 +731,9 @@ struct GenericOffsetTo : OffsetType
|
||||||
return TRACE_RETURN (likely (obj.sanitize (c, user_data)) || neuter (c));
|
return TRACE_RETURN (likely (obj.sanitize (c, user_data)) || neuter (c));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool try_set (hb_sanitize_context_t *c, const OffsetType &v) {
|
|
||||||
if (c->may_edit (this, this->static_size)) {
|
|
||||||
this->set (v);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/* Set the offset to Null */
|
/* Set the offset to Null */
|
||||||
inline bool neuter (hb_sanitize_context_t *c) {
|
inline bool neuter (hb_sanitize_context_t *c) {
|
||||||
if (c->may_edit (this, this->static_size)) {
|
return c->try_set (this, 0);
|
||||||
this->set (0); /* 0 is Null offset */
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <typename Base, typename OffsetType, typename Type>
|
template <typename Base, typename OffsetType, typename Type>
|
||||||
|
|
|
@ -519,7 +519,7 @@ struct Feature
|
||||||
/* Check that it did not overflow. */
|
/* Check that it did not overflow. */
|
||||||
new_offset.set (new_offset_int);
|
new_offset.set (new_offset_int);
|
||||||
if (new_offset == new_offset_int &&
|
if (new_offset == new_offset_int &&
|
||||||
featureParams.try_set (c, new_offset) &&
|
c->try_set (&featureParams, new_offset) &&
|
||||||
!featureParams.sanitize (c, this, closure ? closure->tag : HB_TAG_NONE))
|
!featureParams.sanitize (c, this, closure ? closure->tag : HB_TAG_NONE))
|
||||||
return TRACE_RETURN (false);
|
return TRACE_RETURN (false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue