[pcf] Use unsigned types.

* src/pcf/pcf.h (PCF_Encoding): Use unsigned `enc'.
* src/pcf/pcfdrivr.c (pcf_cmap_char_{index,next}): Ditto.
* src/pcf/pcfread.c (pcf_get_encodings): Use unsigned types.
This commit is contained in:
Alexei Podtelezhnikov 2018-08-06 04:58:18 -04:00
parent 86e7385342
commit f24dbb2811
4 changed files with 34 additions and 29 deletions

View File

@ -1,3 +1,11 @@
2018-08-06 Alexei Podtelezhnikov <apodtele@gmail.com>
[pcf] Use unsigned types.
* src/pcf/pcf.h (PCF_Encoding): Use unsigned `enc'.
* src/pcf/pcfdrivr.c (pcf_cmap_char_{index,next}): Ditto.
* src/pcf/pcfread.c (pcf_get_encodings): Use unsigned types.
2018-08-05 Werner Lemberg <wl@gnu.org>
* src/truetype/ttgload.c (compute_glyph_metrics): Fix overflow.

View File

@ -130,7 +130,7 @@ FT_BEGIN_HEADER
*/
typedef struct PCF_EncodingRec_
{
FT_Long enc;
FT_ULong enc;
FT_UShort glyph; /* an index into PCF_Face's `metrics' array */
} PCF_EncodingRec, *PCF_Encoding;

View File

@ -123,7 +123,7 @@ THE SOFTWARE.
mid = ( min + max ) >> 1;
code = (FT_ULong)encodings[mid].enc;
code = encodings[mid].enc;
if ( charcode == code )
{
@ -161,7 +161,7 @@ THE SOFTWARE.
mid = ( min + max ) >> 1;
code = (FT_ULong)encodings[mid].enc;
code = encodings[mid].enc;
if ( charcode == code )
{
@ -178,7 +178,7 @@ THE SOFTWARE.
charcode = 0;
if ( min < cmap->num_encodings )
{
charcode = (FT_ULong)encodings[min].enc;
charcode = encodings[min].enc;
result = encodings[min].glyph;
}

View File

@ -944,12 +944,12 @@ THE SOFTWARE.
FT_Error error;
FT_Memory memory = FT_FACE( face )->memory;
FT_ULong format, size;
FT_Short firstCol, lastCol;
FT_Short firstRow, lastRow;
FT_UShort firstCol, lastCol;
FT_UShort firstRow, lastRow;
FT_ULong nencoding;
FT_UShort defaultCharRow, defaultCharCol;
FT_UShort encodingOffset, defaultCharEncodingOffset;
FT_Short i, j;
FT_UShort i, j;
FT_Byte* pos;
FT_ULong k;
PCF_Encoding encoding = NULL;
@ -975,18 +975,18 @@ THE SOFTWARE.
/* make sense for most encodings. */
if ( PCF_BYTE_ORDER( format ) == MSBFirst )
{
firstCol = FT_GET_SHORT();
lastCol = FT_GET_SHORT();
firstRow = FT_GET_SHORT();
lastRow = FT_GET_SHORT();
firstCol = FT_GET_USHORT();
lastCol = FT_GET_USHORT();
firstRow = FT_GET_USHORT();
lastRow = FT_GET_USHORT();
face->defaultChar = FT_GET_USHORT();
}
else
{
firstCol = FT_GET_SHORT_LE();
lastCol = FT_GET_SHORT_LE();
firstRow = FT_GET_SHORT_LE();
lastRow = FT_GET_SHORT_LE();
firstCol = FT_GET_USHORT_LE();
lastCol = FT_GET_USHORT_LE();
firstRow = FT_GET_USHORT_LE();
lastRow = FT_GET_USHORT_LE();
face->defaultChar = FT_GET_USHORT_LE();
}
@ -1008,10 +1008,8 @@ THE SOFTWARE.
face->defaultChar ));
/* sanity checks; we limit numbers of rows and columns to 256 */
if ( firstCol < 0 ||
firstCol > lastCol ||
if ( firstCol > lastCol ||
lastCol > 0xFF ||
firstRow < 0 ||
firstRow > lastRow ||
lastRow > 0xFF )
return FT_THROW( Invalid_Table );
@ -1032,14 +1030,14 @@ THE SOFTWARE.
defaultCharCol = face->defaultChar & 0xFF;
/* validate default character */
if ( defaultCharRow < (FT_UShort)firstRow ||
defaultCharRow > (FT_UShort)lastRow ||
defaultCharCol < (FT_UShort)firstCol ||
defaultCharCol > (FT_UShort)lastCol )
if ( defaultCharRow < firstRow ||
defaultCharRow > lastRow ||
defaultCharCol < firstCol ||
defaultCharCol > lastCol )
{
face->defaultChar = (FT_UShort)firstRow * 256U + (FT_UShort)firstCol;
face->defaultChar = firstRow * 256U + firstCol;
FT_TRACE0(( "pcf_get_encodings:"
" Invalid default character set to %d\n",
" Invalid default character set to %u\n",
face->defaultChar ));
defaultCharRow = face->defaultChar >> 8;
@ -1054,9 +1052,8 @@ THE SOFTWARE.
/* `stream->cursor' still points at the beginning of the frame; */
/* we can thus easily get the offset to the default character */
pos = stream->cursor +
2 * ( ( defaultCharRow - (FT_UShort)firstRow ) *
( lastCol - firstCol + 1 ) +
defaultCharCol - (FT_UShort)firstCol );
2 * ( ( defaultCharRow - firstRow ) * ( lastCol - firstCol + 1 ) +
defaultCharCol - firstCol );
if ( PCF_BYTE_ORDER( format ) == MSBFirst )
defaultCharEncodingOffset = FT_PEEK_USHORT( pos );
@ -1102,10 +1099,10 @@ THE SOFTWARE.
else if ( encodingOffset == 0 )
encodingOffset = defaultCharEncodingOffset;
encoding[k].enc = i * 256 + j;
encoding[k].enc = i * 256U + j;
encoding[k].glyph = encodingOffset;
FT_TRACE5(( " code %d (0x%04X): idx %d\n",
FT_TRACE5(( " code %u (0x%04X): idx %u\n",
encoding[k].enc, encoding[k].enc, encoding[k].glyph ));
k++;