From 4a27c17ea0234dfe33e62f5830d9f92c26d48d30 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 27 Oct 2017 14:29:12 -0600 Subject: [PATCH] Fix IntType.cmp() to avoid narrowing down integer types Fixes https://github.com/behdad/harfbuzz/issues/571 --- src/hb-open-type-private.hh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index f25341a8a..f0ff2ff59 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -632,10 +632,11 @@ struct IntType inline bool operator == (const IntType &o) const { return (Type) v == (Type) o.v; } inline bool operator != (const IntType &o) const { return !(*this == o); } static inline int cmp (const IntType *a, const IntType *b) { return b->cmp (*a); } - inline int cmp (Type a) const + template + inline int cmp (Type2 a) const { Type b = v; - if (sizeof (Type) < sizeof (int)) + if (sizeof (Type) < sizeof (int) && sizeof (Type2) < sizeof (int)) return (int) a - (int) b; else return a < b ? -1 : a == b ? 0 : +1;