Check to avoid overflows

This commit is contained in:
Marcel Fabian Krüger 2019-12-17 02:58:51 +01:00 committed by Behdad Esfahbod
parent d70afb1e5a
commit b28c282585
1 changed files with 6 additions and 3 deletions

View File

@ -189,6 +189,9 @@ struct hb_sanitize_context_t :
void start_processing ()
{
reset_object ();
if (unlikely (hb_unsigned_mul_overflows (this->end - this->start, HB_SANITIZE_MAX_OPS_FACTOR)))
this->max_ops = HB_SANITIZE_MAX_OPS_MAX;
else
this->max_ops = hb_min (hb_max ((unsigned int) (this->end - this->start) * HB_SANITIZE_MAX_OPS_FACTOR,
(unsigned) HB_SANITIZE_MAX_OPS_MIN),
(unsigned) HB_SANITIZE_MAX_OPS_MAX);