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

* src/base/ftcalc.c (FT_MulFix) [!FT_LONG64]: Updated.
This commit is contained in:
Alexei Podtelezhnikov 2014-09-03 21:57:42 -04:00
parent 125c3ca8f0
commit 3212852cce
2 changed files with 10 additions and 3 deletions

View File

@ -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.

View File

@ -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
{