Fix hb_in_range() for types smaller than int

As exercised by hb-coretext .notdef code.
This commit is contained in:
Behdad Esfahbod 2014-08-10 18:52:07 -04:00
parent 26a963b9cb
commit c2b151d952
1 changed files with 3 additions and 1 deletions

View File

@ -848,7 +848,9 @@ hb_in_range (T u, T lo, T hi)
* to generate a warning than unused variables. */
ASSERT_STATIC (sizeof (hb_assert_unsigned_t<T>) >= 0);
return (u - lo) <= (hi - lo);
/* The casts below are important as if T is smaller than int,
* the subtract results will become a signed int! */
return (T)(u - lo) <= (T)(hi - lo);
}
template <typename T> static inline bool