fixed a stupid bug in FT_MulFix
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index e2cc4d7..544ca0e 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -325,7 +325,7 @@
FT_Long b )
{
FT_Long s;
-
+ FT_ULong ua, ub;
if ( a == 0 || b == 0x10000L )
return a;
@@ -333,19 +333,22 @@
s = a; a = ABS(a);
s ^= b; b = ABS(b);
- if ( a <= 2048 && b <= 1048576L )
+ ua = (FT_ULong)a;
+ ub = (FT_ULong)b;
+
+ if ( ua <= 2048 && ub <= 1048576L )
{
- a = ( a*b + 0x8000 ) >> 16;
+ ua = ( ua*ub + 0x8000 ) >> 16;
}
else
{
- FT_Long al = a & 0xFFFF;
+ FT_ULong al = ua & 0xFFFF;
- a = (a >> 16)*b + al*(b >> 16) + ( al*(b & 0xFFFF) >> 16 );
+ ua = (ua >> 16)*ub + al*(ub >> 16) + ( al*(ub & 0xFFFF) >> 16 );
}
- return ( s < 0 ? -a : a );
+ return ( s < 0 ? -(FT_Long)ua : ua );
}