[cid] Signedness revisions.

Unsigned checks are simpler.

* include/freetype/t1tables.h (CID_FaceInfoRec): Change to unsignd
`num_dicts`.
* src/cid/cidparse.h (CID_Parser): Change to unsigned `num_dict`.

* src/cid/cidgload.c (cid_load_glyph): Updated.
* src/cid/cidload.c (cid_load_keyword, parse_fd_array,
parse_expansion_factor, parse_font_name, cid_read_subrs,
cid_face_open): Updated.
* src/cid/cidobjs.c (cid_face_done): Updated.
* src/cid/cidparse.c (cid_parser_new): Updated.
This commit is contained in:
Alexei Podtelezhnikov 2021-10-10 23:11:10 -04:00
parent 012b4f2d48
commit 3b036820d6
6 changed files with 23 additions and 28 deletions

View File

@ -419,7 +419,7 @@ FT_BEGIN_HEADER
FT_UInt gd_bytes;
FT_ULong cid_count;
FT_Int num_dicts;
FT_UInt num_dicts;
CID_FaceDict font_dicts;
FT_ULong data_offset;

View File

@ -117,9 +117,9 @@
off2 = cid_get_offset( &p, cid->gd_bytes );
FT_FRAME_EXIT();
if ( fd_select >= (FT_ULong)cid->num_dicts ||
off2 > stream->size ||
off1 > off2 )
if ( fd_select >= cid->num_dicts ||
off2 > stream->size ||
off1 > off2 )
{
FT_TRACE0(( "cid_load_glyph: invalid glyph stream offsets\n" ));
error = FT_THROW( Invalid_Offset );

View File

@ -113,7 +113,7 @@
CID_FaceDict dict;
if ( parser->num_dict < 0 || parser->num_dict >= cid->num_dicts )
if ( parser->num_dict >= cid->num_dicts )
{
FT_ERROR(( "cid_load_keyword: invalid use of `%s'\n",
keyword->ident ));
@ -164,7 +164,7 @@
FT_Fixed temp_scale;
if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
if ( parser->num_dict < face->cid.num_dicts )
{
FT_Matrix* matrix;
FT_Vector* offset;
@ -244,17 +244,12 @@
FT_Memory memory = face->root.memory;
FT_Stream stream = parser->stream;
FT_Error error = FT_Err_Ok;
FT_Long num_dicts;
FT_UInt num_dicts, max_dicts;
num_dicts = cid_parser_to_int( parser );
if ( num_dicts < 0 )
{
FT_ERROR(( "parse_fd_array: invalid number of dictionaries\n" ));
goto Exit;
}
num_dicts = (FT_UInt)cid_parser_to_int( parser );
FT_TRACE4(( " %ld\n", num_dicts ));
FT_TRACE4(( " %u\n", num_dicts ));
/*
* A single entry in the FDArray must (at least) contain the following
@ -272,18 +267,18 @@
* need a `dup X' at the very beginning and a `put' at the end, so a
* rough guess using 100 bytes as the minimum is justified.
*/
if ( (FT_ULong)num_dicts > stream->size / 100 )
max_dicts = (FT_UInt)( stream->size / 100 );
if ( num_dicts > max_dicts )
{
FT_TRACE0(( "parse_fd_array: adjusting FDArray size"
" (from %ld to %lu)\n",
num_dicts,
stream->size / 100 ));
num_dicts = (FT_Long)( stream->size / 100 );
" (from %u to %u)\n",
num_dicts, max_dicts ));
num_dicts = max_dicts;
}
if ( !cid->font_dicts )
{
FT_Int n;
FT_UInt n;
if ( FT_NEW_ARRAY( cid->font_dicts, num_dicts ) )
@ -322,7 +317,7 @@
CID_FaceDict dict;
if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
if ( parser->num_dict < face->cid.num_dicts )
{
dict = face->cid.font_dicts + parser->num_dict;
@ -345,7 +340,7 @@
CID_Parser* parser )
{
#ifdef FT_DEBUG_LEVEL_TRACE
if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
if ( parser->num_dict < face->cid.num_dicts )
{
T1_TokenRec token;
FT_UInt len;
@ -427,7 +422,7 @@
parser->num_dict++;
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE4(( " FontDict %d", parser->num_dict ));
FT_TRACE4(( " FontDict %u", parser->num_dict ));
if ( parser->num_dict > face->cid.num_dicts )
FT_TRACE4(( " (ignored)" ));
FT_TRACE4(( "\n" ));
@ -517,7 +512,7 @@
FT_Memory memory = face->root.memory;
FT_Stream stream = face->cid_stream;
FT_Error error;
FT_Int n;
FT_UInt n;
CID_Subrs subr;
FT_UInt max_offsets = 0;
FT_ULong* offsets = NULL;
@ -771,7 +766,7 @@
CID_Parser* parser;
FT_Memory memory = face->root.memory;
FT_Error error;
FT_Int n;
FT_UInt n;
CID_FaceInfo cid = &face->cid;

View File

@ -216,7 +216,7 @@
/* release subrs */
if ( face->subrs )
{
FT_Int n;
FT_UInt n;
for ( n = 0; n < cid->num_dicts; n++ )

View File

@ -181,7 +181,7 @@
parser->root.base = parser->postscript;
parser->root.cursor = parser->postscript;
parser->root.limit = parser->root.cursor + ps_len;
parser->num_dict = -1;
parser->num_dict = FT_UINT_MAX;
/* Finally, we check whether `StartData' or `/sfnts' was real -- */
/* it could be in a comment or string. We also get the arguments */

View File

@ -78,7 +78,7 @@ FT_BEGIN_HEADER
FT_ULong binary_length;
CID_FaceInfo cid;
FT_Int num_dict;
FT_UInt num_dict;
} CID_Parser;