diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2018-02-23 10:45:03 -0800 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2018-02-23 10:45:03 -0800 |
commit | c2e4713b5b561675b0f7b358ccf83d64ef0b6c41 (patch) | |
tree | ce1bf15c2175897735731596576f499e06ec3a26 /src/hb-ot-hdmx-table.hh | |
parent | 84d4bb91ceca22484abb597c19eb18311e2514f1 (diff) |
[hdmx] Fix sanitize()
Diffstat (limited to 'src/hb-ot-hdmx-table.hh')
-rw-r--r-- | src/hb-ot-hdmx-table.hh | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/hb-ot-hdmx-table.hh b/src/hb-ot-hdmx-table.hh index a4491518..f08fe39d 100644 --- a/src/hb-ot-hdmx-table.hh +++ b/src/hb-ot-hdmx-table.hh @@ -178,27 +178,18 @@ struct hdmx inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - if (unlikely (!c->check_struct (this) || version != 0)) - return_trace (false); - if (unlikely (!c->check_range (this, get_size()))) - return_trace (false); - - for (unsigned int i = 0; i < num_records; i++) - { - if (unlikely (!records[i].sanitize (c, size_device_record))) - return_trace (false); - } - return_trace (true); + return_trace (c->check_struct (this) && version == 0 && + !_hb_unsigned_int_mul_overflows (num_records, size_device_record) && + c->check_range (this, get_size())); } - public: + protected: HBUINT16 version; /* Table version number (0) */ HBUINT16 num_records; /* Number of device records. */ HBUINT32 size_device_record; /* Size of a device record, 32-bit aligned. */ - private: - DeviceRecord records[VAR]; /* Array of device records. */ - public: - DEFINE_SIZE_MIN (8); + HBUINT8 data[VAR]; /* Array of device records. */ + public: + DEFINE_SIZE_ARRAY (8, data); }; } /* namespace OT */ |