diff options
author | Ting-Wei Lan <lantw@src.gnome.org> | 2017-06-05 21:25:12 +0800 |
---|---|---|
committer | Ting-Wei Lan <lantw@src.gnome.org> | 2017-07-18 22:54:58 +0800 |
commit | a3325f632fdb7e993397385bd21c3700d5ec066e (patch) | |
tree | ed1e8c5eebdb4193ff6e719b79934ea8360444ac /pango/fonts.c | |
parent | 7a8744e17fdb8ebb975301813665736667900634 (diff) | |
download | pango-a3325f632fdb7e993397385bd21c3700d5ec066e.tar.gz |
Cast enum to int before doing calculation
It seems that it is possible for compilers to use unsigned interger
types to store enum values, so we should cast them to signed interger
types before doing calculation to avoid getting unexpected results.
https://bugzilla.gnome.org/show_bug.cgi?id=783428
Diffstat (limited to 'pango/fonts.c')
-rw-r--r-- | pango/fonts.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/pango/fonts.c b/pango/fonts.c index da1940f2..887f03cb 100644 --- a/pango/fonts.c +++ b/pango/fonts.c @@ -613,14 +613,14 @@ compute_distance (const PangoFontDescription *a, { if (a->style == b->style) { - return abs(a->weight - b->weight); + return abs((int)(a->weight) - (int)(b->weight)); } else if (a->style != PANGO_STYLE_NORMAL && b->style != PANGO_STYLE_NORMAL) { /* Equate oblique and italic, but with a big penalty */ - return 1000000 + abs (a->weight - b->weight); + return 1000000 + abs ((int)(a->weight) - (int)(b->weight)); } else return G_MAXINT; |