Commit bad0160c1612ac48c94f490ac33318ccccb535e4

Werner Lemberg 2011-08-12T19:50:13

[truetype] Fix degenerate case in S{P,F,DP}VTL opcodes. * src/truetype/ttinterp.c (Ins_SxVTL): Handle p1 == p2 specially. (Ins_SDPVTL): Handle v1 == v2 specially.

diff --git a/ChangeLog b/ChangeLog
index d01132e..cd63208 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-08-12  Werner Lemberg  <wl@gnu.org
+
+	[truetype] Fix degenerate case in S{P,F,DP}VTL opcodes.
+
+	* src/truetype/ttinterp.c (Ins_SxVTL): Handle p1 == p2 specially.
+	(Ins_SDPVTL): Handle v1 == v2 specially.
+
 2011-08-09  Werner Lemberg  <wl@gnu.org>
 
 	Fix Savannah bug #33975.
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index b29aa0e..6c4eed6 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -2845,6 +2845,17 @@
     A = p1->x - p2->x;
     B = p1->y - p2->y;
 
+    /* If p1 == p2, SPVTL and SFVTL behave the same as */
+    /* SPVTCA[X] and SFVTCA[X], respectively.          */
+    /*                                                 */
+    /* Confirmed by Greg Hitchcock.                    */
+
+    if ( A == 0 && B == 0 )
+    {
+      A    = 0x4000;
+      aOpc = 0;
+    }
+
     if ( ( aOpc & 1 ) != 0 )
     {
       C =  B;   /* counter clockwise rotation */
@@ -5181,7 +5192,8 @@
   Ins_SDPVTL( INS_ARG )
   {
     FT_Long    A, B, C;
-    FT_UShort  p1, p2;   /* was FT_Int in pas type ERROR */
+    FT_UShort  p1, p2;            /* was FT_Int in pas type ERROR */
+    FT_Int     aOpc = CUR.opcode;
 
 
     p1 = (FT_UShort)args[1];
@@ -5202,9 +5214,20 @@
 
       A = v1->x - v2->x;
       B = v1->y - v2->y;
+
+      /* If v1 == v2, SDPVTL behaves the same as */
+      /* SVTCA[X], respectively.                 */
+      /*                                         */
+      /* Confirmed by Greg Hitchcock.            */
+
+      if ( A == 0 && B == 0 )
+      {
+        A    = 0x4000;
+        aOpc = 0;
+      }
     }
 
-    if ( ( CUR.opcode & 1 ) != 0 )
+    if ( ( aOpc & 1 ) != 0 )
     {
       C =  B;   /* counter clockwise rotation */
       B =  A;
@@ -5222,7 +5245,7 @@
       B = v1->y - v2->y;
     }
 
-    if ( ( CUR.opcode & 1 ) != 0 )
+    if ( ( aOpc & 1 ) != 0 )
     {
       C =  B;   /* counter clockwise rotation */
       B =  A;