Commit 56751532d3ebd1318742415ad5c7c2667754e60b

Werner Lemberg 2012-06-25T10:58:20

[cff] Fix Savannah bug #36705. Handle numbers like 2.001 correctly. * src/cff/cffparse.c (cff_parse_real): Avoid negative values for `shift'.

diff --git a/ChangeLog b/ChangeLog
index 4e5f716..6228ae8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-06-25  Werner Lemberg  <wl@gnu.org>
+
+	[cff] Fix Savannah bug #36705.
+
+	Handle numbers like 2.001 correctly.
+
+	* src/cff/cffparse.c (cff_parse_real): Avoid negative values for
+	`shift'.
+
 2012-06-18  Infinality  <infinality@infinality.net>
 
 	[truetype] Support subpixel hinting.
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index 61fa87c..ef05043 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    CFF token stream parser (body)                                       */
 /*                                                                         */
-/*  Copyright 1996-2004, 2007-2011 by                                      */
+/*  Copyright 1996-2004, 2007-2012 by                                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -286,15 +286,20 @@
 
             /* Make `scaling' as small as possible. */
             new_fraction_length = FT_MIN( exponent, 5 );
-            exponent           -= new_fraction_length;
             shift               = new_fraction_length - fraction_length;
 
-            number *= power_tens[shift];
-            if ( number > 0x7FFFL )
+            if ( shift > 0 )
             {
-              number   /= 10;
-              exponent += 1;
+              exponent -= new_fraction_length;
+              number   *= power_tens[shift];
+              if ( number > 0x7FFFL )
+              {
+                number   /= 10;
+                exponent += 1;
+              }
             }
+            else
+              exponent -= fraction_length;
           }
           else
             exponent -= fraction_length;