|
|
|
@ -259,34 +259,11 @@ struct hb_sanitize_context_t : |
|
|
|
|
|
|
|
|
|
inline void set_max_ops (int max_ops_) { max_ops = max_ops_; } |
|
|
|
|
|
|
|
|
|
template <typename T> |
|
|
|
|
inline void set_object (const T& obj) |
|
|
|
|
{ |
|
|
|
|
reset_object (); |
|
|
|
|
|
|
|
|
|
const char *obj_start = (const char *) &obj; |
|
|
|
|
const char *obj_end = (const char *) &obj + obj.get_size (); |
|
|
|
|
assert (obj_start <= obj_end); /* Must not overflow. */ |
|
|
|
|
|
|
|
|
|
if (unlikely (obj_end < this->start || this->end < obj_start)) |
|
|
|
|
this->start = this->end = nullptr; |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
this->start = MAX (this->start, obj_start); |
|
|
|
|
this->end = MIN (this->end , obj_end ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline void reset_object (void) |
|
|
|
|
inline void start_processing (void) |
|
|
|
|
{ |
|
|
|
|
this->start = this->blob->data; |
|
|
|
|
this->end = this->start + this->blob->length; |
|
|
|
|
assert (this->start <= this->end); /* Must not overflow. */ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline void start_processing (void) |
|
|
|
|
{ |
|
|
|
|
reset_object (); |
|
|
|
|
this->max_ops = MAX ((unsigned int) (this->end - this->start) * HB_SANITIZE_MAX_OPS_FACTOR, |
|
|
|
|
(unsigned) HB_SANITIZE_MAX_OPS_MIN); |
|
|
|
|
this->edit_count = 0; |
|
|
|
|