ref: 3ea0d2c65a931e721aaf732c17765968bfe755d2
parent: 7962a15d64c876870ca0ae435ea2467d9be268d9
author: Alexei Podtelezhnikov <[email protected]>
date: Sun Sep 13 19:19:34 EDT 2015
* src/base/ftcalc.c (FT_MulFix) [FT_LONG64]: Improve.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-09-14 Alexei Podtelezhnikov <[email protected]>
+
+ * src/base/ftcalc.c (FT_MulFix) [FT_LONG64]: Improve.
+
2015-09-14 Werner Lemberg <[email protected]>
[type1] Fix another potential buffer overflow (#45955).
--- 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 */
}