Fix hb_in_range() for types smaller than int

As exercised by hb-coretext .notdef code.
This commit is contained in:
Behdad Esfahbod committed 2014-08-10 19:05:52 -04:00
1 parent 26a963b9cb
commit c2b151d952
1 file changed
+3 -1
+3 -1
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