freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype][master] 2 commits: [cid] Signedness revisions.


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] 2 commits: [cid] Signedness revisions.
Date: Mon, 11 Oct 2021 03:13:13 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

10 changed files:

Changes:

  • include/freetype/t1tables.h
    ... ... @@ -419,7 +419,7 @@ FT_BEGIN_HEADER
    419 419
         FT_UInt         gd_bytes;
    
    420 420
         FT_ULong        cid_count;
    
    421 421
     
    
    422
    -    FT_Int          num_dicts;
    
    422
    +    FT_UInt         num_dicts;
    
    423 423
         CID_FaceDict    font_dicts;
    
    424 424
     
    
    425 425
         FT_ULong        data_offset;
    

  • src/cid/cidgload.c
    ... ... @@ -117,9 +117,9 @@
    117 117
           off2      = cid_get_offset( &p, cid->gd_bytes );
    
    118 118
           FT_FRAME_EXIT();
    
    119 119
     
    
    120
    -      if ( fd_select >= (FT_ULong)cid->num_dicts ||
    
    121
    -           off2 > stream->size                   ||
    
    122
    -           off1 > off2                           )
    
    120
    +      if ( fd_select >= cid->num_dicts ||
    
    121
    +           off2 > stream->size         ||
    
    122
    +           off1 > off2                 )
    
    123 123
           {
    
    124 124
             FT_TRACE0(( "cid_load_glyph: invalid glyph stream offsets\n" ));
    
    125 125
             error = FT_THROW( Invalid_Offset );
    

  • src/cid/cidload.c
    ... ... @@ -113,7 +113,7 @@
    113 113
             CID_FaceDict  dict;
    
    114 114
     
    
    115 115
     
    
    116
    -        if ( parser->num_dict < 0 || parser->num_dict >= cid->num_dicts )
    
    116
    +        if ( parser->num_dict >= cid->num_dicts )
    
    117 117
             {
    
    118 118
               FT_ERROR(( "cid_load_keyword: invalid use of `%s'\n",
    
    119 119
                          keyword->ident ));
    
    ... ... @@ -164,7 +164,7 @@
    164 164
         FT_Fixed      temp_scale;
    
    165 165
     
    
    166 166
     
    
    167
    -    if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
    
    167
    +    if ( parser->num_dict < face->cid.num_dicts )
    
    168 168
         {
    
    169 169
           FT_Matrix*  matrix;
    
    170 170
           FT_Vector*  offset;
    
    ... ... @@ -244,17 +244,12 @@
    244 244
         FT_Memory     memory = face->root.memory;
    
    245 245
         FT_Stream     stream = parser->stream;
    
    246 246
         FT_Error      error  = FT_Err_Ok;
    
    247
    -    FT_Long       num_dicts;
    
    247
    +    FT_UInt       num_dicts, max_dicts;
    
    248 248
     
    
    249 249
     
    
    250
    -    num_dicts = cid_parser_to_int( parser );
    
    251
    -    if ( num_dicts < 0 )
    
    252
    -    {
    
    253
    -      FT_ERROR(( "parse_fd_array: invalid number of dictionaries\n" ));
    
    254
    -      goto Exit;
    
    255
    -    }
    
    250
    +    num_dicts = (FT_UInt)cid_parser_to_int( parser );
    
    256 251
     
    
    257
    -    FT_TRACE4(( " %ld\n", num_dicts ));
    
    252
    +    FT_TRACE4(( " %u\n", num_dicts ));
    
    258 253
     
    
    259 254
         /*
    
    260 255
          * A single entry in the FDArray must (at least) contain the following
    
    ... ... @@ -272,18 +267,18 @@
    272 267
          * need a `dup X' at the very beginning and a `put' at the end, so a
    
    273 268
          * rough guess using 100 bytes as the minimum is justified.
    
    274 269
          */
    
    275
    -    if ( (FT_ULong)num_dicts > stream->size / 100 )
    
    270
    +    max_dicts = (FT_UInt)( stream->size / 100 );
    
    271
    +    if ( num_dicts > max_dicts )
    
    276 272
         {
    
    277 273
           FT_TRACE0(( "parse_fd_array: adjusting FDArray size"
    
    278
    -                  " (from %ld to %lu)\n",
    
    279
    -                  num_dicts,
    
    280
    -                  stream->size / 100 ));
    
    281
    -      num_dicts = (FT_Long)( stream->size / 100 );
    
    274
    +                  " (from %u to %u)\n",
    
    275
    +                  num_dicts, max_dicts ));
    
    276
    +      num_dicts = max_dicts;
    
    282 277
         }
    
    283 278
     
    
    284 279
         if ( !cid->font_dicts )
    
    285 280
         {
    
    286
    -      FT_Int  n;
    
    281
    +      FT_UInt  n;
    
    287 282
     
    
    288 283
     
    
    289 284
           if ( FT_NEW_ARRAY( cid->font_dicts, num_dicts ) )
    
    ... ... @@ -322,7 +317,7 @@
    322 317
         CID_FaceDict  dict;
    
    323 318
     
    
    324 319
     
    
    325
    -    if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
    
    320
    +    if ( parser->num_dict < face->cid.num_dicts )
    
    326 321
         {
    
    327 322
           dict = face->cid.font_dicts + parser->num_dict;
    
    328 323
     
    
    ... ... @@ -345,7 +340,7 @@
    345 340
                        CID_Parser*  parser )
    
    346 341
       {
    
    347 342
     #ifdef FT_DEBUG_LEVEL_TRACE
    
    348
    -    if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
    
    343
    +    if ( parser->num_dict < face->cid.num_dicts )
    
    349 344
         {
    
    350 345
           T1_TokenRec  token;
    
    351 346
           FT_UInt      len;
    
    ... ... @@ -427,7 +422,7 @@
    427 422
                   parser->num_dict++;
    
    428 423
     
    
    429 424
     #ifdef FT_DEBUG_LEVEL_TRACE
    
    430
    -              FT_TRACE4(( " FontDict %d", parser->num_dict ));
    
    425
    +              FT_TRACE4(( " FontDict %u", parser->num_dict ));
    
    431 426
                   if ( parser->num_dict > face->cid.num_dicts )
    
    432 427
                     FT_TRACE4(( " (ignored)" ));
    
    433 428
                   FT_TRACE4(( "\n" ));
    
    ... ... @@ -517,7 +512,7 @@
    517 512
         FT_Memory      memory = face->root.memory;
    
    518 513
         FT_Stream      stream = face->cid_stream;
    
    519 514
         FT_Error       error;
    
    520
    -    FT_Int         n;
    
    515
    +    FT_UInt        n;
    
    521 516
         CID_Subrs      subr;
    
    522 517
         FT_UInt        max_offsets = 0;
    
    523 518
         FT_ULong*      offsets = NULL;
    
    ... ... @@ -771,7 +766,7 @@
    771 766
         CID_Parser*  parser;
    
    772 767
         FT_Memory    memory = face->root.memory;
    
    773 768
         FT_Error     error;
    
    774
    -    FT_Int       n;
    
    769
    +    FT_UInt      n;
    
    775 770
     
    
    776 771
         CID_FaceInfo  cid = &face->cid;
    
    777 772
     
    

  • src/cid/cidobjs.c
    ... ... @@ -216,7 +216,7 @@
    216 216
         /* release subrs */
    
    217 217
         if ( face->subrs )
    
    218 218
         {
    
    219
    -      FT_Int  n;
    
    219
    +      FT_UInt  n;
    
    220 220
     
    
    221 221
     
    
    222 222
           for ( n = 0; n < cid->num_dicts; n++ )
    

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

  • src/cid/cidparse.h
    ... ... @@ -78,7 +78,7 @@ FT_BEGIN_HEADER
    78 78
         FT_ULong      binary_length;
    
    79 79
     
    
    80 80
         CID_FaceInfo  cid;
    
    81
    -    FT_Int        num_dict;
    
    81
    +    FT_UInt       num_dict;
    
    82 82
     
    
    83 83
       } CID_Parser;
    
    84 84
     
    

  • src/psaux/cffdecode.c
    ... ... @@ -1871,7 +1871,7 @@
    1871 1871
             case cff_op_put:
    
    1872 1872
               {
    
    1873 1873
                 FT_Fixed  val = args[0];
    
    1874
    -            FT_Int    idx = (FT_Int)( args[1] >> 16 );
    
    1874
    +            FT_UInt   idx = (FT_UInt)( args[1] >> 16 );
    
    1875 1875
     
    
    1876 1876
     
    
    1877 1877
                 FT_TRACE4(( " put\n" ));
    
    ... ... @@ -1880,20 +1880,20 @@
    1880 1880
                 /* didn't give a hard-coded size limit of the temporary */
    
    1881 1881
                 /* storage array; instead, an argument of the           */
    
    1882 1882
                 /* `MultipleMaster' operator set the size               */
    
    1883
    -            if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS )
    
    1883
    +            if ( idx < CFF_MAX_TRANS_ELEMENTS )
    
    1884 1884
                   decoder->buildchar[idx] = val;
    
    1885 1885
               }
    
    1886 1886
               break;
    
    1887 1887
     
    
    1888 1888
             case cff_op_get:
    
    1889 1889
               {
    
    1890
    -            FT_Int    idx = (FT_Int)( args[0] >> 16 );
    
    1890
    +            FT_UInt   idx = (FT_UInt)( args[0] >> 16 );
    
    1891 1891
                 FT_Fixed  val = 0;
    
    1892 1892
     
    
    1893 1893
     
    
    1894 1894
                 FT_TRACE4(( " get\n" ));
    
    1895 1895
     
    
    1896
    -            if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS )
    
    1896
    +            if ( idx < CFF_MAX_TRANS_ELEMENTS )
    
    1897 1897
                   val = decoder->buildchar[idx];
    
    1898 1898
     
    
    1899 1899
                 args[0] = val;
    
    ... ... @@ -1914,9 +1914,9 @@
    1914 1914
               /* this operator was removed from the Type2 specification */
    
    1915 1915
               /* in version 16-March-2000                               */
    
    1916 1916
               {
    
    1917
    -            FT_Int  reg_idx = (FT_Int)args[0];
    
    1918
    -            FT_Int  idx     = (FT_Int)args[1];
    
    1919
    -            FT_Int  count   = (FT_Int)args[2];
    
    1917
    +            FT_UInt  reg_idx = (FT_UInt)args[0];
    
    1918
    +            FT_UInt  idx     = (FT_UInt)args[1];
    
    1919
    +            FT_UInt  count   = (FT_UInt)args[2];
    
    1920 1920
     
    
    1921 1921
     
    
    1922 1922
                 FT_TRACE4(( " load\n" ));
    
    ... ... @@ -1924,11 +1924,11 @@
    1924 1924
                 /* since we currently don't handle interpolation of multiple */
    
    1925 1925
                 /* master fonts, we store a vector [1 0 0 ...] in the        */
    
    1926 1926
                 /* temporary storage array regardless of the Registry index  */
    
    1927
    -            if ( reg_idx >= 0 && reg_idx <= 2             &&
    
    1928
    -                 idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS &&
    
    1929
    -                 count >= 0 && count <= num_axes          )
    
    1927
    +            if ( reg_idx <= 2                 &&
    
    1928
    +                 idx < CFF_MAX_TRANS_ELEMENTS &&
    
    1929
    +                 count <= num_axes            )
    
    1930 1930
                 {
    
    1931
    -              FT_Int  end, i;
    
    1931
    +              FT_UInt  end, i;
    
    1932 1932
     
    
    1933 1933
     
    
    1934 1934
                   end = FT_MIN( idx + count, CFF_MAX_TRANS_ELEMENTS );
    

  • src/psaux/psintrp.c
    ... ... @@ -1899,18 +1899,17 @@
    1899 1899
                           /*     cvi( <idx> ) of BuildCharArray with  */
    
    1900 1900
                           /*     WeightVector                         */
    
    1901 1901
                           {
    
    1902
    -                        FT_Int    idx;
    
    1902
    +                        FT_UInt   idx;
    
    1903 1903
                             PS_Blend  blend = decoder->blend;
    
    1904 1904
     
    
    1905 1905
     
    
    1906 1906
                             if ( arg_cnt != 1 || !blend )
    
    1907 1907
                               goto Unexpected_OtherSubr;
    
    1908 1908
     
    
    1909
    -                        idx = cf2_stack_popInt( opStack );
    
    1909
    +                        idx = (FT_UInt)cf2_stack_popInt( opStack );
    
    1910 1910
     
    
    1911
    -                        if ( idx < 0                             ||
    
    1912
    -                             (FT_UInt)idx + blend->num_designs >
    
    1913
    -                               decoder->len_buildchar            )
    
    1911
    +                        if ( idx + blend->num_designs >
    
    1912
    +                               decoder->len_buildchar   )
    
    1914 1913
                               goto Unexpected_OtherSubr;
    
    1915 1914
     
    
    1916 1915
                             ft_memcpy( &decoder->buildchar[idx],
    
    ... ... @@ -2010,17 +2009,16 @@
    2010 2009
                           /* <val> <idx> 2 24 callothersubr               */
    
    2011 2010
                           /* ==> set BuildCharArray[cvi( <idx> )] = <val> */
    
    2012 2011
                           {
    
    2013
    -                        CF2_Int   idx;
    
    2012
    +                        CF2_UInt  idx;
    
    2014 2013
                             PS_Blend  blend = decoder->blend;
    
    2015 2014
     
    
    2016 2015
     
    
    2017 2016
                             if ( arg_cnt != 2 || !blend )
    
    2018 2017
                               goto Unexpected_OtherSubr;
    
    2019 2018
     
    
    2020
    -                        idx = cf2_stack_popInt( opStack );
    
    2019
    +                        idx = (CF2_UInt)cf2_stack_popInt( opStack );
    
    2021 2020
     
    
    2022
    -                        if ( idx < 0                                ||
    
    2023
    -                             (FT_UInt)idx >= decoder->len_buildchar )
    
    2021
    +                        if ( idx >= decoder->len_buildchar )
    
    2024 2022
                               goto Unexpected_OtherSubr;
    
    2025 2023
     
    
    2026 2024
                             decoder->buildchar[idx] =
    
    ... ... @@ -2033,17 +2031,16 @@
    2033 2031
                           /* ==> push BuildCharArray[cvi( idx )] */
    
    2034 2032
                           /*     onto T1 stack                   */
    
    2035 2033
                           {
    
    2036
    -                        CF2_Int   idx;
    
    2034
    +                        CF2_UInt  idx;
    
    2037 2035
                             PS_Blend  blend = decoder->blend;
    
    2038 2036
     
    
    2039 2037
     
    
    2040 2038
                             if ( arg_cnt != 1 || !blend )
    
    2041 2039
                               goto Unexpected_OtherSubr;
    
    2042 2040
     
    
    2043
    -                        idx = cf2_stack_popInt( opStack );
    
    2041
    +                        idx = (CF2_UInt)cf2_stack_popInt( opStack );
    
    2044 2042
     
    
    2045
    -                        if ( idx < 0                                ||
    
    2046
    -                             (FT_UInt)idx >= decoder->len_buildchar )
    
    2043
    +                        if ( idx >= decoder->len_buildchar )
    
    2047 2044
                               goto Unexpected_OtherSubr;
    
    2048 2045
     
    
    2049 2046
                             cf2_stack_pushFixed( opStack,
    
    ... ... @@ -2185,29 +2182,29 @@
    2185 2182
                     case cf2_escPUT:
    
    2186 2183
                       {
    
    2187 2184
                         CF2_F16Dot16  val;
    
    2188
    -                    CF2_Int       idx;
    
    2185
    +                    CF2_UInt      idx;
    
    2189 2186
     
    
    2190 2187
     
    
    2191 2188
                         FT_TRACE4(( " put\n" ));
    
    2192 2189
     
    
    2193
    -                    idx = cf2_stack_popInt( opStack );
    
    2190
    +                    idx = (CF2_UInt)cf2_stack_popInt( opStack );
    
    2194 2191
                         val = cf2_stack_popFixed( opStack );
    
    2195 2192
     
    
    2196
    -                    if ( idx >= 0 && idx < CF2_STORAGE_SIZE )
    
    2193
    +                    if ( idx < CF2_STORAGE_SIZE )
    
    2197 2194
                           storage[idx] = val;
    
    2198 2195
                       }
    
    2199 2196
                       continue; /* do not clear the stack */
    
    2200 2197
     
    
    2201 2198
                     case cf2_escGET:
    
    2202 2199
                       {
    
    2203
    -                    CF2_Int  idx;
    
    2200
    +                    CF2_UInt  idx;
    
    2204 2201
     
    
    2205 2202
     
    
    2206 2203
                         FT_TRACE4(( " get\n" ));
    
    2207 2204
     
    
    2208
    -                    idx = cf2_stack_popInt( opStack );
    
    2205
    +                    idx = (CF2_UInt)cf2_stack_popInt( opStack );
    
    2209 2206
     
    
    2210
    -                    if ( idx >= 0 && idx < CF2_STORAGE_SIZE )
    
    2207
    +                    if ( idx < CF2_STORAGE_SIZE )
    
    2211 2208
                           cf2_stack_pushFixed( opStack, storage[idx] );
    
    2212 2209
                       }
    
    2213 2210
                       continue; /* do not clear the stack */
    

  • src/psaux/t1decode.c
    ... ... @@ -28,7 +28,8 @@
    28 28
     #include "psauxerr.h"
    
    29 29
     
    
    30 30
     /* ensure proper sign extension */
    
    31
    -#define Fix2Int( f )  ( (FT_Int)(FT_Short)( (f) >> 16 ) )
    
    31
    +#define Fix2Int( f )    ( (FT_Int)(FT_Short)( (f) >> 16 ) )
    
    32
    +#define Fix2UInt( f )  ( (FT_UInt)(FT_Short)( (f) >> 16 ) )
    
    32 33
     
    
    33 34
       /**************************************************************************
    
    34 35
        *
    
    ... ... @@ -1025,16 +1026,16 @@
    1025 1026
               /* <val> <idx> 2 24 callothersubr               */
    
    1026 1027
               /* ==> set BuildCharArray[cvi( <idx> )] = <val> */
    
    1027 1028
               {
    
    1028
    -            FT_Int    idx;
    
    1029
    +            FT_UInt   idx;
    
    1029 1030
                 PS_Blend  blend = decoder->blend;
    
    1030 1031
     
    
    1031 1032
     
    
    1032 1033
                 if ( arg_cnt != 2 || !blend )
    
    1033 1034
                   goto Unexpected_OtherSubr;
    
    1034 1035
     
    
    1035
    -            idx = Fix2Int( top[1] );
    
    1036
    +            idx = Fix2UInt( top[1] );
    
    1036 1037
     
    
    1037
    -            if ( idx < 0 || (FT_UInt) idx >= decoder->len_buildchar )
    
    1038
    +            if ( idx >= decoder->len_buildchar )
    
    1038 1039
                   goto Unexpected_OtherSubr;
    
    1039 1040
     
    
    1040 1041
                 decoder->buildchar[idx] = top[0];
    
    ... ... @@ -1046,16 +1047,16 @@
    1046 1047
               /* ==> push BuildCharArray[cvi( idx )] */
    
    1047 1048
               /*     onto T1 stack                   */
    
    1048 1049
               {
    
    1049
    -            FT_Int    idx;
    
    1050
    +            FT_UInt   idx;
    
    1050 1051
                 PS_Blend  blend = decoder->blend;
    
    1051 1052
     
    
    1052 1053
     
    
    1053 1054
                 if ( arg_cnt != 1 || !blend )
    
    1054 1055
                   goto Unexpected_OtherSubr;
    
    1055 1056
     
    
    1056
    -            idx = Fix2Int( top[0] );
    
    1057
    +            idx = Fix2UInt( top[0] );
    
    1057 1058
     
    
    1058
    -            if ( idx < 0 || (FT_UInt) idx >= decoder->len_buildchar )
    
    1059
    +            if ( idx >= decoder->len_buildchar )
    
    1059 1060
                   goto Unexpected_OtherSubr;
    
    1060 1061
     
    
    1061 1062
                 top[0] = decoder->buildchar[idx];
    

  • src/type1/t1load.c
    ... ... @@ -1356,7 +1356,7 @@
    1356 1356
     
    
    1357 1357
         if ( cur < limit && ft_isdigit( *cur ) )
    
    1358 1358
         {
    
    1359
    -      FT_Long  s = T1_ToInt( parser );
    
    1359
    +      FT_ULong  s = (FT_ULong)T1_ToInt( parser );
    
    1360 1360
     
    
    1361 1361
     
    
    1362 1362
           T1_Skip_PS_Token( parser );   /* `RD' or `-|' or something else */
    
    ... ... @@ -1365,10 +1365,10 @@
    1365 1365
           /* `RD' or `-|' token                          */
    
    1366 1366
           *base = parser->root.cursor + 1;
    
    1367 1367
     
    
    1368
    -      if ( s >= 0 && s < limit - *base )
    
    1368
    +      if ( s < (FT_ULong)( limit - *base ) )
    
    1369 1369
           {
    
    1370 1370
             parser->root.cursor += s + 1;
    
    1371
    -        *size = (FT_ULong)s;
    
    1371
    +        *size = s;
    
    1372 1372
             return !parser->root.error;
    
    1373 1373
           }
    
    1374 1374
         }
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]