[kerx] Use subtable range for runtime checks

This commit is contained in:
Behdad Esfahbod 2018-10-09 23:07:47 -04:00
parent 329f240108
commit 948f59a13a
2 changed files with 11 additions and 1 deletions

View File

@ -124,7 +124,7 @@ struct KerxSubTableFormat2
TRACE_APPLY (this); TRACE_APPLY (this);
accelerator_t accel (*this, accelerator_t accel (*this,
c->sanitizer.end, /* XXX Use SubTable length? */ c->sanitizer.end,
c->face->get_num_glyphs ()); c->face->get_num_glyphs ());
hb_kern_machine_t<accelerator_t> machine (accel); hb_kern_machine_t<accelerator_t> machine (accel);
machine.kern (c->font, c->buffer, c->plan->kern_mask); machine.kern (c->font, c->buffer, c->plan->kern_mask);
@ -328,6 +328,8 @@ struct kerx
if (reverse) if (reverse)
c->buffer->reverse (); c->buffer->reverse ();
c->sanitizer.set_object (*table);
/* XXX Reverse-kern is not working yet... /* XXX Reverse-kern is not working yet...
* hb_kern_machine_t would need to know that it's reverse-kerning. * hb_kern_machine_t would need to know that it's reverse-kerning.
* Or better yet, make it work in reverse as well, so we don't have * Or better yet, make it work in reverse as well, so we don't have

View File

@ -254,6 +254,14 @@ struct hb_sanitize_context_t :
inline void set_max_ops (unsigned int max_ops_) { max_ops = max_ops_; } inline void set_max_ops (unsigned int max_ops_) { max_ops = max_ops_; }
template <typename T>
inline void set_object (const T& obj)
{
this->start = (const char *) &obj;
this->end = (const char *) &obj + obj.get_size ();
assert (this->start <= this->end); /* Must not overflow. */
}
inline void start_processing (void) inline void start_processing (void)
{ {
this->start = this->blob->data; this->start = this->blob->data;