Commit a5e9dbd528328fa62432326a1633e2f3d62194f8

Werner Lemberg 2009-11-20T09:33:57

Fix Savannah bug #27742. * src/base/ftstroke.c (ft_stroker_outside): Avoid silent division by zero, using a threshold for `theta'.

diff --git a/ChangeLog b/ChangeLog
index 4032df9..d8c78d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2009-11-20  Werner Lemberg  <wl@gnu.org>
 
+	Fix Savannah bug #27742.
+
+	* src/base/ftstroke.c (ft_stroker_outside): Avoid silent division by
+	zero, using a threshold for `theta'.
+
+2009-11-20  Werner Lemberg  <wl@gnu.org>
+
 	Fix Savannah bug #28036.
 
 	* src/type1/t1afm.c (t1_get_index): Fix comparison.
diff --git a/src/base/ftstroke.c b/src/base/ftstroke.c
index 0978b0e..5005b1c 100644
--- a/src/base/ftstroke.c
+++ b/src/base/ftstroke.c
@@ -979,7 +979,8 @@
       thcos = FT_Cos( theta );
       sigma = FT_MulFix( stroker->miter_limit, thcos );
 
-      if ( sigma >= 0x10000L )
+      /* FT_Sin(x) = 0 for x <= 57 */
+      if ( sigma >= 0x10000L || ft_pos_abs( theta ) <= 57 )
         miter = FALSE;
 
       if ( miter )  /* this is a miter (broken angle) */
@@ -1360,7 +1361,7 @@
         phi1    = (angle_mid + angle_in ) / 2;
         phi2    = (angle_mid + angle_out ) / 2;
         length1 = FT_DivFix( stroker->radius, FT_Cos( theta1 ) );
-        length2 = FT_DivFix( stroker->radius, FT_Cos(theta2) );
+        length2 = FT_DivFix( stroker->radius, FT_Cos( theta2 ) );
 
         for ( side = 0; side <= 1; side++ )
         {