bdf: Fix some data types mismatching with their sources.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
diff --git a/ChangeLog b/ChangeLog
index 2fc961d..6587c0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2009-07-31 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+ bdf: Fix some data types mismatching with their sources.
+
+ * src/bdf/bdrdrivr.c (bdf_cmap_char_index): The type
+ of `code' is matched with BDF_encoding_el->enc.
+ (bdf_cmap_char_next): The type of `charcode' is
+ matched with BDF_encoding_el->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>
+
autofit: Improve Unicode range definitions.
* src/autofit/aftypes.h (AF_UNIRANGE_REC): New macro
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index f681c41..4a91659 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -101,7 +101,7 @@ THE SOFTWARE.
while ( min < max )
{
- FT_UInt32 code;
+ FT_ULong code;
mid = ( min + max ) >> 1;
@@ -133,7 +133,7 @@ THE SOFTWARE.
BDF_encoding_el* encodings = cmap->encodings;
FT_ULong min, max, mid; /* num_encodings */
FT_UShort result = 0; /* encodings->glyph */
- FT_UInt32 charcode = *acharcode + 1;
+ FT_ULong charcode = *acharcode + 1;
min = 0;
@@ -169,7 +169,14 @@ THE SOFTWARE.
}
Exit:
- *acharcode = charcode;
+ if ( charcode > 0xFFFFFFFFUL )
+ {
+ FT_TRACE1(( "bdf_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;
}