[base] Tighten the overflow check in `FT_MulDiv'.

* src/base/ftcalc.c (FT_MulDiv) [!FT_LONG64]: Updated.
This commit is contained in:
Alexei Podtelezhnikov 2014-09-15 22:06:19 -04:00
parent bc12d9e9ac
commit ef070d458b
2 changed files with 8 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2014-09-08 Alexei Podtelezhnikov <apodtele@gmail.com>
[base] Tighten the overflow check in `FT_MulDiv'.
* src/base/ftcalc.c (FT_MulDiv) [!FT_LONG64]: Updated.
2014-09-08 Alexei Podtelezhnikov <apodtele@gmail.com>
Fix Savannah bug #43153.

View File

@ -385,7 +385,7 @@
/* */
/* or, alternatively, */
/* */
/* a + b <= 129895 - (c >> 17) . */
/* a + b <= 129894 - (c >> 17) . */
/* */
/* FT_MulFix, on the other hand, is optimized for a small value of */
/* the first argument, when the second argument can be much larger. */
@ -426,7 +426,7 @@
if ( c == 0 )
a = 0x7FFFFFFFL;
else if ( (FT_ULong)a + b <= 129895UL - ( c >> 17 ) )
else if ( (FT_ULong)a + b <= 129894UL - ( c >> 17 ) )
a = ( (FT_ULong)a * b + ( c >> 1 ) ) / c;
else