[base] Tighten the overflow check in `FT_MulFix'. * src/base/ftcalc.c (FT_MulFix) [!FT_LONG64]: Updated.
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 42 43 44 45 46
diff --git a/ChangeLog b/ChangeLog
index 62ec7ae..dc8d79b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-09-03 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [base] Tighten the overflow check in `FT_MulFix'.
+
+ * src/base/ftcalc.c (FT_MulFix) [!FT_LONG64]: Updated.
+
2014-09-02 Alexei Podtelezhnikov <apodtele@gmail.com>
[truetype] Shortcut ppem calculations for square pixels.
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index a120071..671eec8 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -394,7 +394,8 @@
/* */
/* a + (b >> 8) <= (131071 >> 4) */
/* */
- /* should work well to avoid the overflow. */
+ /* covers the practical range of use. The actual test below is a bit */
+ /* tighter to avoid the border case overflows. */
/* */
/* documentation is in freetype.h */
@@ -524,7 +525,7 @@
ua = (FT_ULong)a;
ub = (FT_ULong)b;
- if ( ua + ( ub >> 8 ) <= 8191UL )
+ if ( ua + ( ub >> 8 ) <= 8190UL )
ua = ( ua * ub + 0x8000U ) >> 16;
else
{
@@ -555,7 +556,7 @@
ua = (FT_ULong)a;
ub = (FT_ULong)b;
- if ( ua + ( ub >> 8 ) <= 8191UL )
+ if ( ua + ( ub >> 8 ) <= 8190UL )
ua = ( ua * ub + 0x8000UL ) >> 16;
else
{