Commit eae89a7f07a8af7304ca258f77d74cd3a8af72ee

suzuki toshiya 2009-08-01T00:30:22

pcf: Fix some data types mismatching with their sources.

diff --git a/ChangeLog b/ChangeLog
index dffb29e..6952632 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2009-07-31  suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
 
+	pcf: Fix some data types mismatching with their sources.
+
+	* src/pcf/pcfdrivr.c (pcf_cmap_char_index): The type of
+	`code' is matched to PCF_Encoding->enc.
+	(pcf_cmap_char_next): The type of `charcode' is matched
+	to PCF_Encoding->enc.  When *acharcode is set by charcode,
+	an overflow is checked and casted to unsigned 32-bit
+	integer.
+
+2009-07-31  suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
 	bdf: Improve bdf_property_t.value names for LP64 platforms.
 
 	* src/bdf/bdf.h: In bdf_property_t.value, the member
diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
index 245de8a..edcd81f 100644
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -111,7 +111,7 @@ THE SOFTWARE.
 
     while ( min < max )
     {
-      FT_UInt32  code;
+      FT_ULong  code;
 
 
       mid  = ( min + max ) >> 1;
@@ -140,7 +140,7 @@ THE SOFTWARE.
     PCF_CMap      cmap      = (PCF_CMap)pcfcmap;
     PCF_Encoding  encodings = cmap->encodings;
     FT_UInt       min, max, mid;
-    FT_UInt32     charcode  = *acharcode + 1;
+    FT_ULong      charcode  = *acharcode + 1;
     FT_UInt       result    = 0;
 
 
@@ -149,7 +149,7 @@ THE SOFTWARE.
 
     while ( min < max )
     {
-      FT_UInt32  code;
+      FT_ULong  code;
 
 
       mid  = ( min + max ) >> 1;
@@ -175,7 +175,14 @@ THE SOFTWARE.
     }
 
   Exit:
-    *acharcode = charcode;
+    if ( charcode > 0xFFFFFFFFUL )
+    {
+      FT_TRACE1(( "pcf_cmap_char_next: charcode 0x%x > 32bit API" ));
+      *acharcode = 0;
+      /* XXX: result should be changed to indicate an overflow error */
+    }
+    else
+      *acharcode = (FT_UInt32)charcode;
     return result;
   }