1
Description: Fix divide by zero checks when casting to 32 bit ints
2
Origin: upstream, http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=ba67957d5ead443f4b6b31805d6e780d54361ca4
4
Index: freetype-2.4.8/src/base/ftcalc.c
5
===================================================================
6
--- freetype-2.4.8.orig/src/base/ftcalc.c 2009-07-31 11:45:18.000000000 -0500
7
+++ freetype-2.4.8/src/base/ftcalc.c 2012-03-20 15:48:23.200375064 -0500
12
- if ( r >= (FT_UInt32)y )
18
if ( a <= 46340L && b <= 46340L && c <= 176095L && c > 0 )
19
a = ( a * b + ( c >> 1 ) ) / c;
22
+ else if ( (FT_Int32)c > 0 )
27
if ( a <= 46340L && b <= 46340L && c > 0 )
31
+ else if ( (FT_Int32)c > 0 )
36
s = (FT_Int32)a; a = FT_ABS( a );
37
s ^= (FT_Int32)b; b = FT_ABS( b );
40
+ if ( (FT_UInt32)b == 0 )
42
/* check for division by 0 */
43
q = (FT_UInt32)0x7FFFFFFFL;
45
else if ( ( a >> 16 ) == 0 )
47
/* compute result directly */
48
- q = (FT_UInt32)( (a << 16) + (b >> 1) ) / (FT_UInt32)b;
49
+ q = (FT_UInt32)( ( a << 16 ) + ( b >> 1 ) ) / (FT_UInt32)b;
53
/* we need more bits; we have to do it by hand */
56
- temp.hi = (FT_Int32) (a >> 16);
57
- temp.lo = (FT_UInt32)(a << 16);
59
+ temp.hi = (FT_Int32) ( a >> 16 );
60
+ temp.lo = (FT_UInt32)( a << 16 );
62
temp2.lo = (FT_UInt32)( b >> 1 );
63
FT_Add64( &temp, &temp2, &temp );