From c986ca15a6320d78471adf950394f391e8729b15 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 15 Jan 2019 13:58:19 -0500 Subject: [PATCH] Improve overflow avoidance Better fix for 480406cd3ef9e5ab8476ddfa04498bf23906c508 This way we behave the same on 32bit and 64bit archs. --- src/hb-machinery.hh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh index 07511e1..f1ac848 100644 --- a/src/hb-machinery.hh +++ b/src/hb-machinery.hh @@ -268,16 +268,12 @@ struct hb_sanitize_context_t : if (!obj) return; const char *obj_start = (const char *) obj; - const char *obj_end = (const char *) obj + obj->get_size (); - - if (unlikely (obj_end < obj_start /* Overflow. */ || - obj_end < this->start || - this->end < obj_start)) + if (unlikely (obj_start < 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 ); + this->start = obj_start; + this->end = obj_start + MIN (this->end - obj_start, obj->get_size ()); } } -- 2.7.4