diff --git a/ChangeLog b/ChangeLog index be16ae00f..cd4fe58e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-09-14 Alexei Podtelezhnikov + + * src/base/ftcalc.c (FT_MulFix) [FT_LONG64]: Improve. + 2015-09-14 Werner Lemberg [type1] Fix another potential buffer overflow (#45955). diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c index dbddedacd..619a08b3a 100644 --- a/src/base/ftcalc.c +++ b/src/base/ftcalc.c @@ -237,22 +237,10 @@ #else - FT_Int s = 1; - FT_UInt64 a, b, c; - FT_Long c_; + FT_Int64 ab = (FT_Int64)a_ * (FT_Int64)b_; - - FT_MOVE_SIGN( a_, s ); - FT_MOVE_SIGN( b_, s ); - - a = (FT_UInt64)a_; - b = (FT_UInt64)b_; - - c = ( a * b + 0x8000UL ) >> 16; - - c_ = (FT_Long)c; - - return s < 0 ? -c_ : c_; + /* this requires arithmetic right shift of signed numbers */ + return (FT_Long)( ( ab + 0x8000L - ( ab < 0 ) ) >> 16 ); #endif /* FT_MULFIX_ASSEMBLER */ }