project
stringclasses 633
values | commit_id
stringlengths 7
81
| target
int64 0
1
| func
stringlengths 5
484k
| cwe
stringclasses 131
values | big_vul_idx
float64 0
189k
⌀ | idx
int64 0
522k
| hash
stringlengths 34
39
| size
float64 1
24k
⌀ | message
stringlengths 0
11.5k
⌀ | dataset
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap13_init( TT_CMap13 cmap,
FT_Byte* table )
{
cmap->cmap.data = table;
table += 12;
cmap->num_groups = FT_PEEK_ULONG( table );
cmap->valid = 0;
return FT_Err_Ok;
}
|
CWE-119
| 7,094 | 15,324 |
308906244898851664365598734154136826423
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap13_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p;
FT_ULong length;
FT_ULong num_groups;
if ( table + 16 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 4;
length = TT_NEXT_ULONG( p );
p = table + 12;
num_groups = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
/* length < 16 + 12 * num_groups ? */
length < 16 ||
( length - 16 ) / 12 < num_groups )
FT_INVALID_TOO_SHORT;
/* check groups, they must be in increasing order */
{
FT_ULong n, start, end, glyph_id, last = 0;
for ( n = 0; n < num_groups; n++ )
{
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
glyph_id = TT_NEXT_ULONG( p );
if ( start > end )
FT_INVALID_DATA;
if ( n > 0 && start <= last )
FT_INVALID_DATA;
if ( valid->level >= FT_VALIDATE_TIGHT )
{
if ( glyph_id >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
last = end;
}
}
return FT_Err_Ok;
}
|
CWE-119
| 7,096 | 15,325 |
227257589104425542284535204286869205658
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
FT_UNUSED( cmap );
FT_UNUSED( char_code );
/* This can't happen */
return 0;
}
|
CWE-119
| 7,097 | 15,326 |
231599273864666806802369169795530788727
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_char_map_def_binary( FT_Byte *base,
FT_UInt32 char_code )
{
FT_UInt32 numRanges = TT_PEEK_ULONG( base );
FT_UInt32 max, min;
min = 0;
max = numRanges;
base += 4;
/* binary search */
while ( min < max )
{
FT_UInt32 mid = ( min + max ) >> 1;
FT_Byte* p = base + 4 * mid;
FT_ULong start = TT_NEXT_UINT24( p );
FT_UInt cnt = FT_NEXT_BYTE( p );
if ( char_code < start )
max = mid;
else if ( char_code > start+cnt )
min = mid + 1;
else
return TRUE;
}
return FALSE;
}
|
CWE-119
| 7,098 | 15,327 |
335465399975573445082047261179361984922
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_char_map_nondef_binary( FT_Byte *base,
FT_UInt32 char_code )
{
FT_UInt32 numMappings = TT_PEEK_ULONG( base );
FT_UInt32 max, min;
min = 0;
max = numMappings;
base += 4;
/* binary search */
while ( min < max )
{
FT_UInt32 mid = ( min + max ) >> 1;
FT_Byte* p = base + 5 * mid;
FT_UInt32 uni = (FT_UInt32)TT_NEXT_UINT24( p );
if ( char_code < uni )
max = mid;
else if ( char_code > uni )
min = mid + 1;
else
return TT_PEEK_USHORT( p );
}
return 0;
}
|
CWE-119
| 7,099 | 15,328 |
247541321062170943292895375948588527808
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
FT_UNUSED( cmap );
/* This can't happen */
*pchar_code = 0;
return 0;
}
|
CWE-119
| 7,100 | 15,329 |
66399457534091224857546755435716731552
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_char_var_index( TT_CMap cmap,
TT_CMap ucmap,
FT_UInt32 charcode,
FT_UInt32 variantSelector )
{
FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector );
FT_ULong defOff;
FT_ULong nondefOff;
if ( !p )
return 0;
defOff = TT_NEXT_ULONG( p );
nondefOff = TT_PEEK_ULONG( p );
if ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff, charcode ) )
{
/* This is the default variant of this charcode. GID not stored */
/* here; stored in the normal Unicode charmap instead. */
return ucmap->cmap.clazz->char_index( &ucmap->cmap, charcode );
}
if ( nondefOff != 0 )
return tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff,
charcode );
return 0;
}
|
CWE-119
| 7,101 | 15,330 |
311067257728547011533211416088023318204
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_char_var_isdefault( TT_CMap cmap,
FT_UInt32 charcode,
FT_UInt32 variantSelector )
{
FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector );
FT_ULong defOff;
FT_ULong nondefOff;
if ( !p )
return -1;
defOff = TT_NEXT_ULONG( p );
nondefOff = TT_NEXT_ULONG( p );
if ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff, charcode ) )
return 1;
if ( nondefOff != 0 &&
tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff,
charcode ) != 0 )
return 0;
return -1;
}
|
CWE-119
| 7,102 | 15,331 |
211238421840386362789541284574800667048
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_char_variants( TT_CMap cmap,
FT_Memory memory,
FT_UInt32 charCode )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 count = cmap14->num_selectors;
FT_Byte* p = cmap->data + 10;
FT_UInt32* q;
if ( tt_cmap14_ensure( cmap14, ( count + 1 ), memory ) )
return NULL;
for ( q = cmap14->results; count > 0; --count )
{
FT_UInt32 varSel = TT_NEXT_UINT24( p );
FT_ULong defOff = TT_NEXT_ULONG( p );
FT_ULong nondefOff = TT_NEXT_ULONG( p );
if ( ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff,
charCode ) ) ||
( nondefOff != 0 &&
tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff,
charCode ) != 0 ) )
{
q[0] = varSel;
q++;
}
}
q[0] = 0;
return cmap14->results;
}
|
CWE-119
| 7,103 | 15,332 |
284713393840250146446978600684011116036
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_def_char_count( FT_Byte *p )
{
FT_UInt32 numRanges = (FT_UInt32)TT_NEXT_ULONG( p );
FT_UInt tot = 0;
p += 3; /* point to the first `cnt' field */
for ( ; numRanges > 0; numRanges-- )
{
tot += 1 + p[0];
p += 4;
}
return tot;
}
|
CWE-119
| 7,104 | 15,333 |
36804598744560995635821602178813324542
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_done( TT_CMap14 cmap )
{
FT_Memory memory = cmap->memory;
cmap->max_results = 0;
if ( memory != NULL && cmap->results != NULL )
FT_FREE( cmap->results );
}
|
CWE-119
| 7,105 | 15,334 |
136620063730487175493845791267785114933
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_ensure( TT_CMap14 cmap,
FT_UInt32 num_results,
FT_Memory memory )
{
FT_UInt32 old_max = cmap->max_results;
FT_Error error = FT_Err_Ok;
if ( num_results > cmap->max_results )
{
cmap->memory = memory;
if ( FT_QRENEW_ARRAY( cmap->results, old_max, num_results ) )
return error;
cmap->max_results = num_results;
}
return error;
}
|
CWE-119
| 7,106 | 15,335 |
89635733241569296199080305468613039541
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_find_variant( FT_Byte *base,
FT_UInt32 variantCode )
{
FT_UInt32 numVar = TT_PEEK_ULONG( base );
FT_UInt32 max, min;
min = 0;
max = numVar;
base += 4;
/* binary search */
while ( min < max )
{
FT_UInt32 mid = ( min + max ) >> 1;
FT_Byte* p = base + 11 * mid;
FT_ULong varSel = TT_NEXT_UINT24( p );
if ( variantCode < varSel )
max = mid;
else if ( variantCode > varSel )
min = mid + 1;
else
return p;
}
return NULL;
}
|
CWE-119
| 7,107 | 15,336 |
187677058723033702629983458585258340756
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_get_def_chars( TT_CMap cmap,
FT_Byte* p,
FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 numRanges;
FT_UInt cnt;
FT_UInt32* q;
cnt = tt_cmap14_def_char_count( p );
numRanges = (FT_UInt32)TT_NEXT_ULONG( p );
if ( tt_cmap14_ensure( cmap14, ( cnt + 1 ), memory ) )
return NULL;
for ( q = cmap14->results; numRanges > 0; --numRanges )
{
FT_UInt32 uni = (FT_UInt32)TT_NEXT_UINT24( p );
cnt = FT_NEXT_BYTE( p ) + 1;
do
{
q[0] = uni;
uni += 1;
q += 1;
} while ( --cnt != 0 );
}
q[0] = 0;
return cmap14->results;
}
|
CWE-119
| 7,108 | 15,337 |
301679334388332248413402485934744160440
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_UNUSED( cmap );
cmap_info->format = 14;
/* subtable 14 does not define a language field */
cmap_info->language = 0xFFFFFFFFUL;
return FT_Err_Ok;
}
|
CWE-119
| 7,109 | 15,338 |
58759014647500858435175146239284911425
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_get_nondef_chars( TT_CMap cmap,
FT_Byte *p,
FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 numMappings;
FT_UInt i;
FT_UInt32 *ret;
numMappings = (FT_UInt32)TT_NEXT_ULONG( p );
if ( tt_cmap14_ensure( cmap14, ( numMappings + 1 ), memory ) )
return NULL;
ret = cmap14->results;
for ( i = 0; i < numMappings; ++i )
{
ret[i] = (FT_UInt32)TT_NEXT_UINT24( p );
p += 2;
}
ret[i] = 0;
return ret;
}
|
CWE-119
| 7,110 | 15,339 |
189611451298866279312172501101433486032
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_init( TT_CMap14 cmap,
FT_Byte* table )
{
cmap->cmap.data = table;
table += 6;
cmap->num_selectors = FT_PEEK_ULONG( table );
cmap->max_results = 0;
cmap->results = NULL;
return FT_Err_Ok;
}
|
CWE-119
| 7,111 | 15,340 |
310307163362607463251741745306178202895
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p;
FT_ULong length;
FT_ULong num_selectors;
if ( table + 2 + 4 + 4 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 2;
length = TT_NEXT_ULONG( p );
num_selectors = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
/* length < 10 + 11 * num_selectors ? */
length < 10 ||
( length - 10 ) / 11 < num_selectors )
FT_INVALID_TOO_SHORT;
/* check selectors, they must be in increasing order */
{
/* we start lastVarSel at 1 because a variant selector value of 0
* isn't valid.
*/
FT_ULong n, lastVarSel = 1;
for ( n = 0; n < num_selectors; n++ )
{
FT_ULong varSel = TT_NEXT_UINT24( p );
FT_ULong defOff = TT_NEXT_ULONG( p );
FT_ULong nondefOff = TT_NEXT_ULONG( p );
if ( defOff >= length || nondefOff >= length )
FT_INVALID_TOO_SHORT;
if ( varSel < lastVarSel )
FT_INVALID_DATA;
lastVarSel = varSel + 1;
/* check the default table (these glyphs should be reached */
/* through the normal Unicode cmap, no GIDs, just check order) */
if ( defOff != 0 )
{
FT_Byte* defp = table + defOff;
FT_ULong numRanges = TT_NEXT_ULONG( defp );
FT_ULong i;
FT_ULong lastBase = 0;
/* defp + numRanges * 4 > valid->limit ? */
if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 )
FT_INVALID_TOO_SHORT;
for ( i = 0; i < numRanges; ++i )
{
FT_ULong base = TT_NEXT_UINT24( defp );
FT_ULong cnt = FT_NEXT_BYTE( defp );
if ( base + cnt >= 0x110000UL ) /* end of Unicode */
FT_INVALID_DATA;
if ( base < lastBase )
FT_INVALID_DATA;
lastBase = base + cnt + 1U;
}
}
/* and the non-default table (these glyphs are specified here) */
if ( nondefOff != 0 )
{
FT_Byte* ndp = table + nondefOff;
FT_ULong numMappings = TT_NEXT_ULONG( ndp );
FT_ULong i, lastUni = 0;
/* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */
if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 )
FT_INVALID_TOO_SHORT;
for ( i = 0; i < numMappings; ++i )
{
FT_ULong uni = TT_NEXT_UINT24( ndp );
FT_ULong gid = TT_NEXT_USHORT( ndp );
if ( uni >= 0x110000UL ) /* end of Unicode */
FT_INVALID_DATA;
if ( uni < lastUni )
FT_INVALID_DATA;
lastUni = uni + 1U;
if ( valid->level >= FT_VALIDATE_TIGHT &&
gid >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
}
}
return FT_Err_Ok;
}
|
CWE-119
| 7,112 | 15,341 |
273333863066697572197403498362263550813
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_variant_chars( TT_CMap cmap,
FT_Memory memory,
FT_UInt32 variantSelector )
{
FT_Byte *p = tt_cmap14_find_variant( cmap->data + 6,
variantSelector );
FT_Int i;
FT_ULong defOff;
FT_ULong nondefOff;
if ( !p )
return NULL;
defOff = TT_NEXT_ULONG( p );
nondefOff = TT_NEXT_ULONG( p );
if ( defOff == 0 && nondefOff == 0 )
return NULL;
if ( defOff == 0 )
return tt_cmap14_get_nondef_chars( cmap, cmap->data + nondefOff,
memory );
else if ( nondefOff == 0 )
return tt_cmap14_get_def_chars( cmap, cmap->data + defOff,
memory );
else
{
/* Both a default and a non-default glyph set? That's probably not */
/* good font design, but the spec allows for it... */
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 numRanges;
FT_UInt32 numMappings;
FT_UInt32 duni;
FT_UInt32 dcnt;
FT_UInt32 nuni;
FT_Byte* dp;
FT_UInt di, ni, k;
FT_UInt32 *ret;
p = cmap->data + nondefOff;
dp = cmap->data + defOff;
numMappings = (FT_UInt32)TT_NEXT_ULONG( p );
dcnt = tt_cmap14_def_char_count( dp );
numRanges = (FT_UInt32)TT_NEXT_ULONG( dp );
if ( numMappings == 0 )
return tt_cmap14_get_def_chars( cmap, cmap->data + defOff,
memory );
if ( dcnt == 0 )
return tt_cmap14_get_nondef_chars( cmap, cmap->data + nondefOff,
memory );
if ( tt_cmap14_ensure( cmap14, ( dcnt + numMappings + 1 ), memory ) )
return NULL;
ret = cmap14->results;
duni = (FT_UInt32)TT_NEXT_UINT24( dp );
dcnt = FT_NEXT_BYTE( dp );
di = 1;
nuni = (FT_UInt32)TT_NEXT_UINT24( p );
p += 2;
ni = 1;
i = 0;
for ( ;; )
{
if ( nuni > duni + dcnt )
{
for ( k = 0; k <= dcnt; ++k )
ret[i++] = duni + k;
++di;
if ( di > numRanges )
break;
duni = (FT_UInt32)TT_NEXT_UINT24( dp );
dcnt = FT_NEXT_BYTE( dp );
}
else
{
if ( nuni < duni )
ret[i++] = nuni;
/* If it is within the default range then ignore it -- */
/* that should not have happened */
++ni;
if ( ni > numMappings )
break;
nuni = (FT_UInt32)TT_NEXT_UINT24( p );
p += 2;
}
}
if ( ni <= numMappings )
{
/* If we get here then we have run out of all default ranges. */
/* We have read one non-default mapping which we haven't stored */
/* and there may be others that need to be read. */
ret[i++] = nuni;
while ( ni < numMappings )
{
ret[i++] = (FT_UInt32)TT_NEXT_UINT24( p );
p += 2;
++ni;
}
}
else if ( di <= numRanges )
{
/* If we get here then we have run out of all non-default */
/* mappings. We have read one default range which we haven't */
/* stored and there may be others that need to be read. */
for ( k = 0; k <= dcnt; ++k )
ret[i++] = duni + k;
while ( di < numRanges )
{
duni = (FT_UInt32)TT_NEXT_UINT24( dp );
dcnt = FT_NEXT_BYTE( dp );
for ( k = 0; k <= dcnt; ++k )
ret[i++] = duni + k;
++di;
}
}
ret[i] = 0;
return ret;
}
}
|
CWE-119
| 7,113 | 15,342 |
114161772929137251024492828407482099284
| null | null | null |
savannah
|
9bd20b7304aae61de5d50ac359cf27132bafd4c1
| 0 |
tt_cmap14_variants( TT_CMap cmap,
FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14)cmap;
FT_UInt32 count = cmap14->num_selectors;
FT_Byte* p = cmap->data + 10;
FT_UInt32* result;
FT_UInt32 i;
if ( tt_cmap14_ensure( cmap14, ( count + 1 ), memory ) )
return NULL;
result = cmap14->results;
for ( i = 0; i < count; ++i )
{
result[i] = (FT_UInt32)TT_NEXT_UINT24( p );
p += 8;
}
result[i] = 0;
return result;
}
|
CWE-119
| 7,114 | 15,343 |
163650617490447596590002584048462580925
| null | null | null |
savannah
|
42fcd6693ec7bd6ffc65ddc63e74287a65dda669
| 0 |
T42_Open_Face( T42_Face face )
{
T42_LoaderRec loader;
T42_Parser parser;
T1_Font type1 = &face->type1;
FT_Memory memory = face->root.memory;
FT_Error error;
PSAux_Service psaux = (PSAux_Service)face->psaux;
t42_loader_init( &loader, face );
parser = &loader.parser;
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
/* while parsing the font we always update `face->ttf_size' so that */
/* even in case of buggy data (which might lead to premature end of */
/* scanning without causing an error) the call to `FT_Open_Face' in */
/* `T42_Face_Init' passes the correct size */
face->ttf_size = 12;
error = t42_parser_init( parser,
face->root.stream,
memory,
psaux);
if ( error )
goto Exit;
error = t42_parse_dict( face, &loader,
parser->base_dict, parser->base_len );
if ( error )
goto Exit;
if ( type1->font_type != 42 )
{
FT_ERROR(( "T42_Open_Face: cannot handle FontType %d\n",
type1->font_type ));
error = FT_THROW( Unknown_File_Format );
goto Exit;
}
/* now, propagate the charstrings and glyphnames tables */
/* to the Type1 data */
type1->num_glyphs = loader.num_glyphs;
if ( !loader.charstrings.init )
{
FT_ERROR(( "T42_Open_Face: no charstrings array in face\n" ));
error = FT_THROW( Invalid_File_Format );
}
loader.charstrings.init = 0;
type1->charstrings_block = loader.charstrings.block;
type1->charstrings = loader.charstrings.elements;
type1->charstrings_len = loader.charstrings.lengths;
/* we copy the glyph names `block' and `elements' fields; */
/* the `lengths' field must be released later */
type1->glyph_names_block = loader.glyph_names.block;
type1->glyph_names = (FT_String**)loader.glyph_names.elements;
loader.glyph_names.block = 0;
loader.glyph_names.elements = 0;
/* we must now build type1.encoding when we have a custom array */
if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
{
FT_Int charcode, idx, min_char, max_char;
FT_Byte* glyph_name;
/* OK, we do the following: for each element in the encoding */
/* table, look up the index of the glyph having the same name */
/* as defined in the CharStrings array. */
/* The index is then stored in type1.encoding.char_index, and */
/* the name in type1.encoding.char_name */
min_char = 0;
max_char = 0;
charcode = 0;
for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
{
FT_Byte* char_name;
type1->encoding.char_index[charcode] = 0;
type1->encoding.char_name [charcode] = (char *)".notdef";
char_name = loader.encoding_table.elements[charcode];
if ( char_name )
for ( idx = 0; idx < type1->num_glyphs; idx++ )
{
glyph_name = (FT_Byte*)type1->glyph_names[idx];
if ( ft_strcmp( (const char*)char_name,
(const char*)glyph_name ) == 0 )
{
type1->encoding.char_index[charcode] = (FT_UShort)idx;
type1->encoding.char_name [charcode] = (char*)glyph_name;
/* Change min/max encoded char only if glyph name is */
/* not /.notdef */
if ( ft_strcmp( (const char*)".notdef",
(const char*)glyph_name ) != 0 )
{
if ( charcode < min_char )
min_char = charcode;
if ( charcode >= max_char )
max_char = charcode + 1;
}
break;
}
}
}
type1->encoding.code_first = min_char;
type1->encoding.code_last = max_char;
type1->encoding.num_chars = loader.num_chars;
}
Exit:
t42_loader_done( &loader );
return error;
}
| 7,117 | 15,344 |
23945568238899323409384022721223441784
| null | null | null |
|
savannah
|
f70d9342e65cd2cb44e9f26b6d7edeedf191fc6c
| 0 |
tt_face_done_kern( TT_Face face )
{
FT_Stream stream = face->root.stream;
FT_FRAME_RELEASE( face->kern_table );
face->kern_table_size = 0;
face->num_kern_tables = 0;
face->kern_avail_bits = 0;
face->kern_order_bits = 0;
}
|
CWE-125
| 7,169 | 15,390 |
40587064965586856732994915068453191477
| null | null | null |
savannah
|
f70d9342e65cd2cb44e9f26b6d7edeedf191fc6c
| 0 |
tt_face_get_kerning( TT_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph )
{
FT_Int result = 0;
FT_UInt count, mask;
FT_Byte* p = face->kern_table;
FT_Byte* p_limit = p + face->kern_table_size;
p += 4;
mask = 0x0001;
for ( count = face->num_kern_tables;
count > 0 && p + 6 <= p_limit;
count--, mask <<= 1 )
{
FT_Byte* base = p;
FT_Byte* next;
FT_UInt version = FT_NEXT_USHORT( p );
FT_UInt length = FT_NEXT_USHORT( p );
FT_UInt coverage = FT_NEXT_USHORT( p );
FT_UInt num_pairs;
FT_Int value = 0;
FT_UNUSED( version );
next = base + length;
if ( next > p_limit ) /* handle broken table */
next = p_limit;
if ( ( face->kern_avail_bits & mask ) == 0 )
goto NextTable;
if ( p + 8 > next )
goto NextTable;
num_pairs = FT_NEXT_USHORT( p );
p += 6;
if ( ( next - p ) < 6 * (int)num_pairs ) /* handle broken count */
num_pairs = (FT_UInt)( ( next - p ) / 6 );
switch ( coverage >> 8 )
{
case 0:
{
FT_ULong key0 = TT_KERN_INDEX( left_glyph, right_glyph );
if ( face->kern_order_bits & mask ) /* binary search */
{
FT_UInt min = 0;
FT_UInt max = num_pairs;
while ( min < max )
{
FT_UInt mid = ( min + max ) >> 1;
FT_Byte* q = p + 6 * mid;
FT_ULong key;
key = FT_NEXT_ULONG( q );
if ( key == key0 )
{
value = FT_PEEK_SHORT( q );
goto Found;
}
if ( key < key0 )
min = mid + 1;
else
max = mid;
}
}
else /* linear search */
{
FT_UInt count2;
for ( count2 = num_pairs; count2 > 0; count2-- )
{
FT_ULong key = FT_NEXT_ULONG( p );
if ( key == key0 )
{
value = FT_PEEK_SHORT( p );
goto Found;
}
p += 2;
}
}
}
break;
/*
* We don't support format 2 because we haven't seen a single font
* using it in real life...
*/
default:
;
}
goto NextTable;
Found:
if ( coverage & 8 ) /* override or add */
result = value;
else
result += value;
NextTable:
p = next;
}
return result;
}
|
CWE-125
| 7,170 | 15,391 |
205750294213544749057934684157080039642
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
T1_ToBool( PS_Parser parser )
{
return ps_tobool( &parser->cursor, parser->limit );
}
|
CWE-119
| 7,339 | 15,481 |
294994986558467317918856546244485203789
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
T1_ToString( PS_Parser parser )
{
return ps_tostring( &parser->cursor, parser->limit, parser->memory );
}
|
CWE-119
| 7,340 | 15,482 |
189723889043950158337711081483937145749
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_parser_done( PS_Parser parser )
{
FT_UNUSED( parser );
}
|
CWE-119
| 7,341 | 15,483 |
204514365680096296903876548466018240864
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_parser_init( PS_Parser parser,
FT_Byte* base,
FT_Byte* limit,
FT_Memory memory )
{
parser->error = FT_Err_Ok;
parser->base = base;
parser->limit = limit;
parser->cursor = base;
parser->memory = memory;
parser->funcs = ps_parser_funcs;
}
|
CWE-119
| 7,342 | 15,484 |
98365591098591696007157916047720556986
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_parser_load_field( PS_Parser parser,
const T1_Field field,
void** objects,
FT_UInt max_objects,
FT_ULong* pflags )
{
T1_TokenRec token;
FT_Byte* cur;
FT_Byte* limit;
FT_UInt count;
FT_UInt idx;
FT_Error error;
T1_FieldType type;
/* this also skips leading whitespace */
ps_parser_to_token( parser, &token );
if ( !token.type )
goto Fail;
count = 1;
idx = 0;
cur = token.start;
limit = token.limit;
type = field->type;
/* we must detect arrays in /FontBBox */
if ( type == T1_FIELD_TYPE_BBOX )
{
T1_TokenRec token2;
FT_Byte* old_cur = parser->cursor;
FT_Byte* old_limit = parser->limit;
/* don't include delimiters */
parser->cursor = token.start + 1;
parser->limit = token.limit - 1;
ps_parser_to_token( parser, &token2 );
parser->cursor = old_cur;
parser->limit = old_limit;
if ( token2.type == T1_TOKEN_TYPE_ARRAY )
{
type = T1_FIELD_TYPE_MM_BBOX;
goto FieldArray;
}
}
else if ( token.type == T1_TOKEN_TYPE_ARRAY )
{
count = max_objects;
FieldArray:
/* if this is an array and we have no blend, an error occurs */
if ( max_objects == 0 )
goto Fail;
idx = 1;
/* don't include delimiters */
cur++;
limit--;
}
for ( ; count > 0; count--, idx++ )
{
FT_Byte* q = (FT_Byte*)objects[idx] + field->offset;
FT_Long val;
FT_String* string = NULL;
skip_spaces( &cur, limit );
switch ( type )
{
case T1_FIELD_TYPE_BOOL:
val = ps_tobool( &cur, limit );
goto Store_Integer;
case T1_FIELD_TYPE_FIXED:
val = PS_Conv_ToFixed( &cur, limit, 0 );
goto Store_Integer;
case T1_FIELD_TYPE_FIXED_1000:
val = PS_Conv_ToFixed( &cur, limit, 3 );
goto Store_Integer;
case T1_FIELD_TYPE_INTEGER:
val = PS_Conv_ToInt( &cur, limit );
/* fall through */
Store_Integer:
switch ( field->size )
{
case (8 / FT_CHAR_BIT):
*(FT_Byte*)q = (FT_Byte)val;
break;
case (16 / FT_CHAR_BIT):
*(FT_UShort*)q = (FT_UShort)val;
break;
case (32 / FT_CHAR_BIT):
*(FT_UInt32*)q = (FT_UInt32)val;
break;
default: /* for 64-bit systems */
*(FT_Long*)q = val;
}
break;
case T1_FIELD_TYPE_STRING:
case T1_FIELD_TYPE_KEY:
{
FT_Memory memory = parser->memory;
FT_UInt len = (FT_UInt)( limit - cur );
if ( cur >= limit )
break;
/* we allow both a string or a name */
/* for cases like /FontName (foo) def */
if ( token.type == T1_TOKEN_TYPE_KEY )
{
/* don't include leading `/' */
len--;
cur++;
}
else if ( token.type == T1_TOKEN_TYPE_STRING )
{
/* don't include delimiting parentheses */
/* XXX we don't handle <<...>> here */
/* XXX should we convert octal escapes? */
/* if so, what encoding should we use? */
cur++;
len -= 2;
}
else
{
FT_ERROR(( "ps_parser_load_field:"
" expected a name or string\n"
" "
" but found token of type %d instead\n",
token.type ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
/* for this to work (FT_String**)q must have been */
/* initialized to NULL */
if ( *(FT_String**)q )
{
FT_TRACE0(( "ps_parser_load_field: overwriting field %s\n",
field->ident ));
FT_FREE( *(FT_String**)q );
*(FT_String**)q = NULL;
}
if ( FT_ALLOC( string, len + 1 ) )
goto Exit;
FT_MEM_COPY( string, cur, len );
string[len] = 0;
*(FT_String**)q = string;
}
break;
case T1_FIELD_TYPE_BBOX:
{
FT_Fixed temp[4];
FT_BBox* bbox = (FT_BBox*)q;
FT_Int result;
result = ps_tofixedarray( &cur, limit, 4, temp, 0 );
if ( result < 4 )
{
FT_ERROR(( "ps_parser_load_field:"
" expected four integers in bounding box\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
bbox->xMin = FT_RoundFix( temp[0] );
bbox->yMin = FT_RoundFix( temp[1] );
bbox->xMax = FT_RoundFix( temp[2] );
bbox->yMax = FT_RoundFix( temp[3] );
}
break;
case T1_FIELD_TYPE_MM_BBOX:
{
FT_Memory memory = parser->memory;
FT_Fixed* temp = NULL;
FT_Int result;
FT_UInt i;
if ( FT_NEW_ARRAY( temp, max_objects * 4 ) )
goto Exit;
for ( i = 0; i < 4; i++ )
{
result = ps_tofixedarray( &cur, limit, (FT_Int)max_objects,
temp + i * max_objects, 0 );
if ( result < 0 || (FT_UInt)result < max_objects )
{
FT_ERROR(( "ps_parser_load_field:"
" expected %d integer%s in the %s subarray\n"
" "
" of /FontBBox in the /Blend dictionary\n",
max_objects, max_objects > 1 ? "s" : "",
i == 0 ? "first"
: ( i == 1 ? "second"
: ( i == 2 ? "third"
: "fourth" ) ) ));
error = FT_THROW( Invalid_File_Format );
FT_FREE( temp );
goto Exit;
}
skip_spaces( &cur, limit );
}
for ( i = 0; i < max_objects; i++ )
{
FT_BBox* bbox = (FT_BBox*)objects[i];
bbox->xMin = FT_RoundFix( temp[i ] );
bbox->yMin = FT_RoundFix( temp[i + max_objects] );
bbox->xMax = FT_RoundFix( temp[i + 2 * max_objects] );
bbox->yMax = FT_RoundFix( temp[i + 3 * max_objects] );
}
FT_FREE( temp );
}
break;
default:
/* an error occurred */
goto Fail;
}
}
#if 0 /* obsolete -- keep for reference */
if ( pflags )
*pflags |= 1L << field->flag_bit;
#else
FT_UNUSED( pflags );
#endif
error = FT_Err_Ok;
Exit:
return error;
Fail:
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
|
CWE-119
| 7,343 | 15,485 |
247904654475830722848278636319479345861
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_parser_load_field_table( PS_Parser parser,
const T1_Field field,
void** objects,
FT_UInt max_objects,
FT_ULong* pflags )
{
T1_TokenRec elements[T1_MAX_TABLE_ELEMENTS];
T1_Token token;
FT_Int num_elements;
FT_Error error = FT_Err_Ok;
FT_Byte* old_cursor;
FT_Byte* old_limit;
T1_FieldRec fieldrec = *(T1_Field)field;
fieldrec.type = T1_FIELD_TYPE_INTEGER;
if ( field->type == T1_FIELD_TYPE_FIXED_ARRAY ||
field->type == T1_FIELD_TYPE_BBOX )
fieldrec.type = T1_FIELD_TYPE_FIXED;
ps_parser_to_token_array( parser, elements,
T1_MAX_TABLE_ELEMENTS, &num_elements );
if ( num_elements < 0 )
{
error = FT_ERR( Ignore );
goto Exit;
}
if ( (FT_UInt)num_elements > field->array_max )
num_elements = (FT_Int)field->array_max;
old_cursor = parser->cursor;
old_limit = parser->limit;
/* we store the elements count if necessary; */
/* we further assume that `count_offset' can't be zero */
if ( field->type != T1_FIELD_TYPE_BBOX && field->count_offset != 0 )
*(FT_Byte*)( (FT_Byte*)objects[0] + field->count_offset ) =
(FT_Byte)num_elements;
/* we now load each element, adjusting the field.offset on each one */
token = elements;
for ( ; num_elements > 0; num_elements--, token++ )
{
parser->cursor = token->start;
parser->limit = token->limit;
error = ps_parser_load_field( parser,
&fieldrec,
objects,
max_objects,
0 );
if ( error )
break;
fieldrec.offset += fieldrec.size;
}
#if 0 /* obsolete -- keep for reference */
if ( pflags )
*pflags |= 1L << field->flag_bit;
#else
FT_UNUSED( pflags );
#endif
parser->cursor = old_cursor;
parser->limit = old_limit;
Exit:
return error;
}
|
CWE-119
| 7,344 | 15,486 |
165370865708939207366111774925693606221
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_parser_skip_PS_token( PS_Parser parser )
{
/* Note: PostScript allows any non-delimiting, non-whitespace */
/* character in a name (PS Ref Manual, 3rd ed, p31). */
/* PostScript delimiters are (, ), <, >, [, ], {, }, /, and %. */
FT_Byte* cur = parser->cursor;
FT_Byte* limit = parser->limit;
FT_Error error = FT_Err_Ok;
skip_spaces( &cur, limit ); /* this also skips comments */
if ( cur >= limit )
goto Exit;
/* self-delimiting, single-character tokens */
if ( *cur == '[' || *cur == ']' )
{
cur++;
goto Exit;
}
/* skip balanced expressions (procedures and strings) */
if ( *cur == '{' ) /* {...} */
{
error = skip_procedure( &cur, limit );
goto Exit;
}
if ( *cur == '(' ) /* (...) */
{
error = skip_literal_string( &cur, limit );
goto Exit;
}
if ( *cur == '<' ) /* <...> */
{
if ( cur + 1 < limit && *(cur + 1) == '<' ) /* << */
{
cur++;
cur++;
}
else
error = skip_string( &cur, limit );
goto Exit;
}
if ( *cur == '>' )
{
cur++;
if ( cur >= limit || *cur != '>' ) /* >> */
{
FT_ERROR(( "ps_parser_skip_PS_token:"
" unexpected closing delimiter `>'\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
cur++;
goto Exit;
}
if ( *cur == '/' )
cur++;
/* anything else */
while ( cur < limit )
{
/* *cur might be invalid (e.g., ')' or '}'), but this */
/* is handled by the test `cur == parser->cursor' below */
if ( IS_PS_DELIM( *cur ) )
break;
cur++;
}
Exit:
if ( cur < limit && cur == parser->cursor )
{
FT_ERROR(( "ps_parser_skip_PS_token:"
" current token is `%c' which is self-delimiting\n"
" "
" but invalid at this point\n",
*cur ));
error = FT_THROW( Invalid_File_Format );
}
if ( cur > limit )
cur = limit;
parser->error = error;
parser->cursor = cur;
}
|
CWE-119
| 7,345 | 15,487 |
34528019881985796086350689866227536607
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_parser_skip_spaces( PS_Parser parser )
{
skip_spaces( &parser->cursor, parser->limit );
}
|
CWE-119
| 7,346 | 15,488 |
5981104221782698160977590320742050988
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_parser_to_bytes( PS_Parser parser,
FT_Byte* bytes,
FT_Offset max_bytes,
FT_ULong* pnum_bytes,
FT_Bool delimiters )
{
FT_Error error = FT_Err_Ok;
FT_Byte* cur;
ps_parser_skip_spaces( parser );
cur = parser->cursor;
if ( cur >= parser->limit )
goto Exit;
if ( delimiters )
{
if ( *cur != '<' )
{
FT_ERROR(( "ps_parser_to_bytes: Missing starting delimiter `<'\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
cur++;
}
*pnum_bytes = PS_Conv_ASCIIHexDecode( &cur,
parser->limit,
bytes,
max_bytes );
if ( delimiters )
{
if ( cur < parser->limit && *cur != '>' )
{
FT_ERROR(( "ps_parser_to_bytes: Missing closing delimiter `>'\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
cur++;
}
parser->cursor = cur;
Exit:
return error;
}
|
CWE-119
| 7,347 | 15,489 |
76033277462059760386406335542333254826
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_parser_to_coord_array( PS_Parser parser,
FT_Int max_coords,
FT_Short* coords )
{
ps_parser_skip_spaces( parser );
return ps_tocoordarray( &parser->cursor, parser->limit,
max_coords, coords );
}
|
CWE-119
| 7,348 | 15,490 |
106781165934391948807529419531621599246
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_parser_to_fixed( PS_Parser parser,
FT_Int power_ten )
{
ps_parser_skip_spaces( parser );
return PS_Conv_ToFixed( &parser->cursor, parser->limit, power_ten );
}
|
CWE-119
| 7,349 | 15,491 |
247774831609700049926628452916741949411
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_parser_to_fixed_array( PS_Parser parser,
FT_Int max_values,
FT_Fixed* values,
FT_Int power_ten )
{
ps_parser_skip_spaces( parser );
return ps_tofixedarray( &parser->cursor, parser->limit,
max_values, values, power_ten );
}
|
CWE-119
| 7,350 | 15,492 |
113344866561645180378827898328312998452
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_parser_to_int( PS_Parser parser )
{
ps_parser_skip_spaces( parser );
return PS_Conv_ToInt( &parser->cursor, parser->limit );
}
|
CWE-119
| 7,351 | 15,493 |
315694978379469424821669740922176995878
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_parser_to_token_array( PS_Parser parser,
T1_Token tokens,
FT_UInt max_tokens,
FT_Int* pnum_tokens )
{
T1_TokenRec master;
*pnum_tokens = -1;
/* this also handles leading whitespace */
ps_parser_to_token( parser, &master );
if ( master.type == T1_TOKEN_TYPE_ARRAY )
{
FT_Byte* old_cursor = parser->cursor;
FT_Byte* old_limit = parser->limit;
T1_Token cur = tokens;
T1_Token limit = cur + max_tokens;
/* don't include outermost delimiters */
parser->cursor = master.start + 1;
parser->limit = master.limit - 1;
while ( parser->cursor < parser->limit )
{
T1_TokenRec token;
ps_parser_to_token( parser, &token );
if ( !token.type )
break;
if ( tokens && cur < limit )
*cur = token;
cur++;
}
*pnum_tokens = (FT_Int)( cur - tokens );
parser->cursor = old_cursor;
parser->limit = old_limit;
}
}
|
CWE-119
| 7,352 | 15,494 |
253646613603121440078318693265191839628
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_table_add( PS_Table table,
FT_Int idx,
void* object,
FT_UInt length )
{
if ( idx < 0 || idx >= table->max_elems )
{
FT_ERROR(( "ps_table_add: invalid index\n" ));
return FT_THROW( Invalid_Argument );
}
/* grow the base block if needed */
if ( table->cursor + length > table->capacity )
{
FT_Error error;
FT_Offset new_size = table->capacity;
FT_PtrDist in_offset;
in_offset = (FT_Byte*)object - table->block;
if ( in_offset < 0 || (FT_Offset)in_offset >= table->capacity )
in_offset = -1;
while ( new_size < table->cursor + length )
{
/* increase size by 25% and round up to the nearest multiple
of 1024 */
new_size += ( new_size >> 2 ) + 1;
new_size = FT_PAD_CEIL( new_size, 1024 );
}
error = reallocate_t1_table( table, new_size );
if ( error )
return error;
if ( in_offset >= 0 )
object = table->block + in_offset;
}
/* add the object to the base block and adjust offset */
table->elements[idx] = table->block + table->cursor;
table->lengths [idx] = length;
FT_MEM_COPY( table->block + table->cursor, object, length );
table->cursor += length;
return FT_Err_Ok;
}
|
CWE-119
| 7,353 | 15,495 |
256276990714376165739562973501577899934
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_table_done( PS_Table table )
{
FT_Memory memory = table->memory;
FT_Error error;
FT_Byte* old_base = table->block;
/* should never fail, because rec.cursor <= rec.size */
if ( !old_base )
return;
if ( FT_ALLOC( table->block, table->cursor ) )
return;
FT_MEM_COPY( table->block, old_base, table->cursor );
shift_elements( table, old_base );
table->capacity = table->cursor;
FT_FREE( old_base );
FT_UNUSED( error );
}
|
CWE-119
| 7,354 | 15,496 |
2673390561940927996680238174922297895
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_table_release( PS_Table table )
{
FT_Memory memory = table->memory;
if ( (FT_ULong)table->init == 0xDEADBEEFUL )
{
FT_FREE( table->block );
FT_FREE( table->elements );
FT_FREE( table->lengths );
table->init = 0;
}
}
|
CWE-119
| 7,356 | 15,497 |
28478788646821443488171789554935954846
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_tobool( FT_Byte* *acur,
FT_Byte* limit )
{
FT_Byte* cur = *acur;
FT_Bool result = 0;
/* return 1 if we find `true', 0 otherwise */
if ( cur + 3 < limit &&
cur[0] == 't' &&
cur[1] == 'r' &&
cur[2] == 'u' &&
cur[3] == 'e' )
{
result = 1;
cur += 5;
}
else if ( cur + 4 < limit &&
cur[0] == 'f' &&
cur[1] == 'a' &&
cur[2] == 'l' &&
cur[3] == 's' &&
cur[4] == 'e' )
{
result = 0;
cur += 6;
}
*acur = cur;
return result;
}
|
CWE-119
| 7,357 | 15,498 |
252214661298246081299022516947135921439
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_tofixedarray( FT_Byte* *acur,
FT_Byte* limit,
FT_Int max_values,
FT_Fixed* values,
FT_Int power_ten )
{
FT_Byte* cur = *acur;
FT_Int count = 0;
FT_Byte c, ender;
if ( cur >= limit )
goto Exit;
/* Check for the beginning of an array. Otherwise, only one number */
/* will be read. */
c = *cur;
ender = 0;
if ( c == '[' )
ender = ']';
else if ( c == '{' )
ender = '}';
if ( ender )
cur++;
/* now, read the values */
while ( cur < limit )
{
FT_Fixed dummy;
FT_Byte* old_cur;
/* skip whitespace in front of data */
skip_spaces( &cur, limit );
if ( cur >= limit )
goto Exit;
if ( *cur == ender )
{
cur++;
break;
}
old_cur = cur;
if ( values && count >= max_values )
break;
/* call PS_Conv_ToFixed() even if coords == NULL */
/* to properly parse number at `cur' */
*( values ? &values[count] : &dummy ) =
PS_Conv_ToFixed( &cur, limit, power_ten );
if ( old_cur == cur )
{
count = -1;
goto Exit;
}
else
count++;
if ( !ender )
break;
}
Exit:
*acur = cur;
return count;
}
|
CWE-119
| 7,358 | 15,499 |
3797599106537132250237983672787164960
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
ps_tostring( FT_Byte** cursor,
FT_Byte* limit,
FT_Memory memory )
{
FT_Byte* cur = *cursor;
FT_UInt len = 0;
FT_Int count;
FT_String* result;
FT_Error error;
/* XXX: some stupid fonts have a `Notice' or `Copyright' string */
/* that simply doesn't begin with an opening parenthesis, even */
/* though they have a closing one! E.g. "amuncial.pfb" */
/* */
/* We must deal with these ill-fated cases there. Note that */
/* these fonts didn't work with the old Type 1 driver as the */
/* notice/copyright was not recognized as a valid string token */
/* and made the old token parser commit errors. */
while ( cur < limit && ( *cur == ' ' || *cur == '\t' ) )
cur++;
if ( cur + 1 >= limit )
return 0;
if ( *cur == '(' )
cur++; /* skip the opening parenthesis, if there is one */
*cursor = cur;
count = 0;
/* then, count its length */
for ( ; cur < limit; cur++ )
{
if ( *cur == '(' )
count++;
else if ( *cur == ')' )
{
count--;
if ( count < 0 )
break;
}
}
len = (FT_UInt)( cur - *cursor );
if ( cur >= limit || FT_ALLOC( result, len + 1 ) )
return 0;
/* now copy the string */
FT_MEM_COPY( result, *cursor, len );
result[len] = '\0';
*cursor = cur;
return result;
}
|
CWE-119
| 7,359 | 15,500 |
297846644816344024634347894187241829288
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
reallocate_t1_table( PS_Table table,
FT_Offset new_size )
{
FT_Memory memory = table->memory;
FT_Byte* old_base = table->block;
FT_Error error;
/* allocate new base block */
if ( FT_ALLOC( table->block, new_size ) )
{
table->block = old_base;
return error;
}
/* copy elements and shift offsets */
if ( old_base )
{
FT_MEM_COPY( table->block, old_base, table->capacity );
shift_elements( table, old_base );
FT_FREE( old_base );
}
table->capacity = new_size;
return FT_Err_Ok;
}
|
CWE-119
| 7,360 | 15,501 |
22447920291984884448417592741495324830
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
shift_elements( PS_Table table,
FT_Byte* old_base )
{
FT_PtrDist delta = table->block - old_base;
FT_Byte** offset = table->elements;
FT_Byte** limit = offset + table->max_elems;
for ( ; offset < limit; offset++ )
{
if ( offset[0] )
offset[0] += delta;
}
}
|
CWE-119
| 7,361 | 15,502 |
26181650610740117448481331489998225870
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
skip_comment( FT_Byte* *acur,
FT_Byte* limit )
{
FT_Byte* cur = *acur;
while ( cur < limit )
{
if ( IS_PS_NEWLINE( *cur ) )
break;
cur++;
}
*acur = cur;
}
|
CWE-119
| 7,362 | 15,503 |
193443508859067749469573928002901073915
| null | null | null |
savannah
|
3774fc08b502c3e685afca098b6e8a195aded6a0
| 0 |
skip_literal_string( FT_Byte* *acur,
FT_Byte* limit )
{
FT_Byte* cur = *acur;
FT_Int embed = 0;
FT_Error error = FT_ERR( Invalid_File_Format );
unsigned int i;
while ( cur < limit )
{
FT_Byte c = *cur;
cur++;
if ( c == '\\' )
{
/* Red Book 3rd ed., section `Literal Text Strings', p. 29: */
/* A backslash can introduce three different types */
/* of escape sequences: */
/* - a special escaped char like \r, \n, etc. */
/* - a one-, two-, or three-digit octal number */
/* - none of the above in which case the backslash is ignored */
if ( cur == limit )
/* error (or to be ignored?) */
break;
switch ( *cur )
{
/* skip `special' escape */
case 'n':
case 'r':
case 't':
case 'b':
case 'f':
case '\\':
case '(':
case ')':
cur++;
break;
default:
/* skip octal escape or ignore backslash */
for ( i = 0; i < 3 && cur < limit; i++ )
{
if ( !IS_OCTAL_DIGIT( *cur ) )
break;
cur++;
}
}
}
else if ( c == '(' )
embed++;
else if ( c == ')' )
{
embed--;
if ( embed == 0 )
{
error = FT_Err_Ok;
break;
}
}
}
*acur = cur;
return error;
}
|
CWE-119
| 7,363 | 15,504 |
67333592029602787429278365253069583046
| null | null | null |
savannah
|
f958c48ee431bef8d4d466b40c9cb2d4dbcb7791
| 0 |
t1_decoder_done( T1_Decoder decoder )
{
t1_builder_done( &decoder->builder );
}
|
CWE-787
| 7,466 | 15,517 |
224589897833240265860765295669098414252
| null | null | null |
savannah
|
f958c48ee431bef8d4d466b40c9cb2d4dbcb7791
| 0 |
t1_decoder_init( T1_Decoder decoder,
FT_Face face,
FT_Size size,
FT_GlyphSlot slot,
FT_Byte** glyph_names,
PS_Blend blend,
FT_Bool hinting,
FT_Render_Mode hint_mode,
T1_Decoder_Callback parse_callback )
{
FT_ZERO( decoder );
/* retrieve PSNames interface from list of current modules */
{
FT_Service_PsCMaps psnames;
FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
if ( !psnames )
{
FT_ERROR(( "t1_decoder_init:"
" the `psnames' module is not available\n" ));
return FT_THROW( Unimplemented_Feature );
}
decoder->psnames = psnames;
}
t1_builder_init( &decoder->builder, face, size, slot, hinting );
/* decoder->buildchar and decoder->len_buildchar have to be */
/* initialized by the caller since we cannot know the length */
/* of the BuildCharArray */
decoder->num_glyphs = (FT_UInt)face->num_glyphs;
decoder->glyph_names = glyph_names;
decoder->hint_mode = hint_mode;
decoder->blend = blend;
decoder->parse_callback = parse_callback;
decoder->funcs = t1_decoder_funcs;
return FT_Err_Ok;
}
|
CWE-787
| 7,467 | 15,518 |
182239179511661477491876276582023299598
| null | null | null |
savannah
|
f958c48ee431bef8d4d466b40c9cb2d4dbcb7791
| 0 |
t1_decoder_parse_glyph( T1_Decoder decoder,
FT_UInt glyph )
{
return decoder->parse_callback( decoder, glyph );
}
|
CWE-787
| 7,468 | 15,519 |
126740819317615175081043736209167758625
| null | null | null |
savannah
|
f958c48ee431bef8d4d466b40c9cb2d4dbcb7791
| 0 |
t1_lookup_glyph_by_stdcharcode( T1_Decoder decoder,
FT_Int charcode )
{
FT_UInt n;
const FT_String* glyph_name;
FT_Service_PsCMaps psnames = decoder->psnames;
/* check range of standard char code */
if ( charcode < 0 || charcode > 255 )
return -1;
glyph_name = psnames->adobe_std_strings(
psnames->adobe_std_encoding[charcode]);
for ( n = 0; n < decoder->num_glyphs; n++ )
{
FT_String* name = (FT_String*)decoder->glyph_names[n];
if ( name &&
name[0] == glyph_name[0] &&
ft_strcmp( name, glyph_name ) == 0 )
return (FT_Int)n;
}
return -1;
}
|
CWE-787
| 7,469 | 15,520 |
307615158016272103346226964509171221696
| null | null | null |
dbus
|
7d65a3a6ed8815e34a99c680ac3869fde49dbbd4
| 0 |
generate_from_message (DBusString *data,
DBusValidity *expected_validity,
DBusMessage *message)
{
dbus_message_set_serial (message, 1);
dbus_message_lock (message);
*expected_validity = DBUS_VALID;
/* move for efficiency, since we'll nuke the message anyway */
if (!_dbus_string_move (&message->header.data, 0,
data, 0))
_dbus_assert_not_reached ("oom");
if (!_dbus_string_copy (&message->body, 0,
data, _dbus_string_get_length (data)))
_dbus_assert_not_reached ("oom");
}
|
CWE-399
| 7,490 | 15,521 |
41601949078840943069921099164703375955
| null | null | null |
dbus
|
7d65a3a6ed8815e34a99c680ac3869fde49dbbd4
| 0 |
generate_many_bodies (DBusMessageDataIter *iter,
DBusString *data,
DBusValidity *expected_validity)
{
return generate_outer (iter, data, expected_validity,
generate_many_bodies_inner);
}
|
CWE-399
| 7,491 | 15,522 |
230745137978787721955565667611503509331
| null | null | null |
dbus
|
7d65a3a6ed8815e34a99c680ac3869fde49dbbd4
| 0 |
generate_many_bodies_inner (DBusMessageDataIter *iter,
DBusMessage **message_p)
{
DBusMessage *message;
DBusString signature;
DBusString body;
/* Keeping this small makes things go faster */
message = dbus_message_new_method_call ("o.z.F",
"/",
"o.z.B",
"Nah");
if (message == NULL)
_dbus_assert_not_reached ("oom");
set_reply_serial (message);
if (!_dbus_string_init (&signature) || !_dbus_string_init (&body))
_dbus_assert_not_reached ("oom");
if (dbus_internal_do_not_use_generate_bodies (iter_get_sequence (iter),
message->byte_order,
&signature, &body))
{
const char *v_SIGNATURE;
v_SIGNATURE = _dbus_string_get_const_data (&signature);
if (!_dbus_header_set_field_basic (&message->header,
DBUS_HEADER_FIELD_SIGNATURE,
DBUS_TYPE_SIGNATURE,
&v_SIGNATURE))
_dbus_assert_not_reached ("oom");
if (!_dbus_string_move (&body, 0, &message->body, 0))
_dbus_assert_not_reached ("oom");
_dbus_marshal_set_uint32 (&message->header.data, BODY_LENGTH_OFFSET,
_dbus_string_get_length (&message->body),
message->byte_order);
*message_p = message;
}
else
{
dbus_message_unref (message);
*message_p = NULL;
}
_dbus_string_free (&signature);
_dbus_string_free (&body);
return *message_p != NULL;
}
|
CWE-399
| 7,492 | 15,523 |
242269604840938593957611521423925476383
| null | null | null |
dbus
|
7d65a3a6ed8815e34a99c680ac3869fde49dbbd4
| 0 |
generate_outer (DBusMessageDataIter *iter,
DBusString *data,
DBusValidity *expected_validity,
DBusInnerGeneratorFunc func)
{
DBusMessage *message;
message = NULL;
if (!(*func)(iter, &message))
return FALSE;
iter_next (iter);
_dbus_assert (message != NULL);
generate_from_message (data, expected_validity, message);
dbus_message_unref (message);
return TRUE;
}
|
CWE-399
| 7,493 | 15,524 |
120324000702646788629185296747017217280
| null | null | null |
dbus
|
7d65a3a6ed8815e34a99c680ac3869fde49dbbd4
| 0 |
generate_trivial (DBusMessageDataIter *iter,
DBusString *data,
DBusValidity *expected_validity)
{
return generate_outer (iter, data, expected_validity,
generate_trivial_inner);
}
|
CWE-399
| 7,494 | 15,525 |
190901897376288257950426476514726415663
| null | null | null |
dbus
|
7d65a3a6ed8815e34a99c680ac3869fde49dbbd4
| 0 |
generate_trivial_inner (DBusMessageDataIter *iter,
DBusMessage **message_p)
{
DBusMessage *message;
switch (iter_get_sequence (iter))
{
case 0:
message = dbus_message_new_method_call ("org.freedesktop.TextEditor",
"/foo/bar",
"org.freedesktop.DocumentFactory",
"Create");
break;
case 1:
message = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN);
set_reply_serial (message);
break;
case 2:
message = dbus_message_new_signal ("/foo/bar",
"org.freedesktop.DocumentFactory",
"Created");
break;
case 3:
message = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR);
if (!dbus_message_set_error_name (message,
"org.freedesktop.TestErrorName"))
_dbus_assert_not_reached ("oom");
{
DBusMessageIter iter;
const char *v_STRING = "This is an error";
dbus_message_iter_init_append (message, &iter);
if (!dbus_message_iter_append_basic (&iter,
DBUS_TYPE_STRING,
&v_STRING))
_dbus_assert_not_reached ("oom");
}
set_reply_serial (message);
break;
default:
return FALSE;
}
if (message == NULL)
_dbus_assert_not_reached ("oom");
*message_p = message;
return TRUE;
}
|
CWE-399
| 7,495 | 15,526 |
318680581642263048839027983861438410224
| null | null | null |
dbus
|
7d65a3a6ed8815e34a99c680ac3869fde49dbbd4
| 0 |
iter_first_in_series (DBusMessageDataIter *iter)
{
int i;
i = iter->depth;
while (i < _DBUS_MESSAGE_DATA_MAX_NESTING)
{
if (iter->sequence_nos[i] != 0)
return FALSE;
++i;
}
return TRUE;
}
|
CWE-399
| 7,496 | 15,527 |
188115245383009211703208378950176102776
| null | null | null |
dbus
|
7d65a3a6ed8815e34a99c680ac3869fde49dbbd4
| 0 |
iter_get_sequence (DBusMessageDataIter *iter)
{
_dbus_assert (iter->sequence_nos[iter->depth] >= 0);
return iter->sequence_nos[iter->depth];
}
|
CWE-399
| 7,497 | 15,528 |
221356969408150865717853862273373132331
| null | null | null |
dbus
|
7d65a3a6ed8815e34a99c680ac3869fde49dbbd4
| 0 |
iter_next (DBusMessageDataIter *iter)
{
iter->sequence_nos[iter->depth] += 1;
}
|
CWE-399
| 7,498 | 15,529 |
176776801012477486591659601427008743253
| null | null | null |
dbus
|
7d65a3a6ed8815e34a99c680ac3869fde49dbbd4
| 0 |
iter_unrecurse (DBusMessageDataIter *iter)
{
iter->depth -= 1;
_dbus_assert (iter->depth >= 0);
}
|
CWE-399
| 7,501 | 15,530 |
33004287291713159930008987462863459311
| null | null | null |
dbus
|
7d65a3a6ed8815e34a99c680ac3869fde49dbbd4
| 0 |
simple_error (void)
{
DBusMessage *message;
message = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR);
if (message == NULL)
_dbus_assert_not_reached ("oom");
if (!dbus_message_set_error_name (message, "foo.bar"))
_dbus_assert_not_reached ("oom");
set_reply_serial (message);
return message;
}
|
CWE-399
| 7,503 | 15,531 |
280712834982746001955954627698327320786
| null | null | null |
dbus
|
7d65a3a6ed8815e34a99c680ac3869fde49dbbd4
| 0 |
simple_method_call (void)
{
DBusMessage *message;
/* Keeping this small makes stuff go faster */
message = dbus_message_new_method_call ("o.b.Q",
"/f/b",
"o.b.Z",
"Fro");
if (message == NULL)
_dbus_assert_not_reached ("oom");
return message;
}
|
CWE-399
| 7,504 | 15,532 |
224698980712701655404865456284313155477
| null | null | null |
dbus
|
7d65a3a6ed8815e34a99c680ac3869fde49dbbd4
| 0 |
simple_signal (void)
{
DBusMessage *message;
message = dbus_message_new_signal ("/f/b",
"o.b.Z",
"Fro");
if (message == NULL)
_dbus_assert_not_reached ("oom");
return message;
}
|
CWE-399
| 7,506 | 15,533 |
324077772911321266895818512904804214569
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_check_single_notdef( FT_Face ttface )
{
FT_Bool result = FALSE;
TT_Face face = (TT_Face)ttface;
FT_UInt asize;
FT_ULong i;
FT_ULong glyph_index = 0;
FT_UInt count = 0;
for( i = 0; i < face->num_locations; i++ )
{
tt_face_get_location( face, i, &asize );
if ( asize > 0 )
{
count += 1;
if ( count > 1 )
break;
glyph_index = i;
}
}
/* Only have a single outline. */
if ( count == 1 )
{
if ( glyph_index == 0 )
result = TRUE;
else
{
/* FIXME: Need to test glyphname == .notdef ? */
FT_Error error;
char buf[8];
error = FT_Get_Glyph_Name( ttface, glyph_index, buf, 8 );
if ( !error &&
buf[0] == '.' && !ft_strncmp( buf, ".notdef", 8 ) )
result = TRUE;
}
}
return result;
}
|
CWE-787
| 7,507 | 15,534 |
188509867572422836298113314270313241675
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_check_trickyness_family( FT_String* name )
{
#define TRICK_NAMES_MAX_CHARACTERS 19
#define TRICK_NAMES_COUNT 9
static const char trick_names[TRICK_NAMES_COUNT]
[TRICK_NAMES_MAX_CHARACTERS + 1] =
{
"DFKaiSho-SB", /* dfkaisb.ttf */
"DFKaiShu",
"DFKai-SB", /* kaiu.ttf */
"HuaTianKaiTi?", /* htkt2.ttf */
"HuaTianSongTi?", /* htst3.ttf */
"Ming(for ISO10646)", /* hkscsiic.ttf & iicore.ttf */
"MingLiU", /* mingliu.ttf & mingliu.ttc */
"PMingLiU", /* mingliu.ttc */
"MingLi43", /* mingli.ttf */
};
int nn;
for ( nn = 0; nn < TRICK_NAMES_COUNT; nn++ )
if ( ft_strstr( name, trick_names[nn] ) )
return TRUE;
return FALSE;
}
|
CWE-787
| 7,509 | 15,535 |
182561401272641062806593457612618772831
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_driver_done( FT_Module ttdriver ) /* TT_Driver */
{
FT_UNUSED( ttdriver );
}
|
CWE-787
| 7,510 | 15,536 |
270360789459194487662668282455311208497
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_driver_init( FT_Module ttdriver ) /* TT_Driver */
{
#ifdef TT_USE_BYTECODE_INTERPRETER
TT_Driver driver = (TT_Driver)ttdriver;
driver->interpreter_version = TT_INTERPRETER_VERSION_35;
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
driver->interpreter_version = TT_INTERPRETER_VERSION_38;
#endif
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
driver->interpreter_version = TT_INTERPRETER_VERSION_40;
#endif
#else /* !TT_USE_BYTECODE_INTERPRETER */
FT_UNUSED( ttdriver );
#endif /* !TT_USE_BYTECODE_INTERPRETER */
return FT_Err_Ok;
}
|
CWE-787
| 7,511 | 15,537 |
122856108945458785735068248133053063961
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_face_done( FT_Face ttface ) /* TT_Face */
{
TT_Face face = (TT_Face)ttface;
FT_Memory memory;
FT_Stream stream;
SFNT_Service sfnt;
if ( !face )
return;
memory = ttface->memory;
stream = ttface->stream;
sfnt = (SFNT_Service)face->sfnt;
/* for `extended TrueType formats' (i.e. compressed versions) */
if ( face->extra.finalizer )
face->extra.finalizer( face->extra.data );
if ( sfnt )
sfnt->done_face( face );
/* freeing the locations table */
tt_face_done_loca( face );
tt_face_free_hdmx( face );
/* freeing the CVT */
FT_FREE( face->cvt );
face->cvt_size = 0;
/* freeing the programs */
FT_FRAME_RELEASE( face->font_program );
FT_FRAME_RELEASE( face->cvt_program );
face->font_program_size = 0;
face->cvt_program_size = 0;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
tt_done_blend( face );
face->blend = NULL;
#endif
}
|
CWE-787
| 7,512 | 15,538 |
60925592219942826418190867072769828865
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_face_init( FT_Stream stream,
FT_Face ttface, /* TT_Face */
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
FT_Error error;
FT_Library library;
SFNT_Service sfnt;
TT_Face face = (TT_Face)ttface;
FT_TRACE2(( "TTF driver\n" ));
library = ttface->driver->root.library;
sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
if ( !sfnt )
{
FT_ERROR(( "tt_face_init: cannot access `sfnt' module\n" ));
error = FT_THROW( Missing_Module );
goto Exit;
}
/* create input stream from resource */
if ( FT_STREAM_SEEK( 0 ) )
goto Exit;
/* check that we have a valid TrueType file */
FT_TRACE2(( " " ));
error = sfnt->init_face( stream, face, face_index, num_params, params );
/* Stream may have changed. */
stream = face->root.stream;
if ( error )
goto Exit;
/* We must also be able to accept Mac/GX fonts, as well as OT ones. */
/* The 0x00020000 tag is completely undocumented; some fonts from */
/* Arphic made for Chinese Windows 3.1 have this. */
if ( face->format_tag != 0x00010000L && /* MS fonts */
face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */
face->format_tag != TTAG_true ) /* Mac fonts */
{
FT_TRACE2(( " not a TTF font\n" ));
goto Bad_Format;
}
#ifdef TT_USE_BYTECODE_INTERPRETER
ttface->face_flags |= FT_FACE_FLAG_HINTER;
#endif
/* If we are performing a simple font format check, exit immediately. */
if ( face_index < 0 )
return FT_Err_Ok;
/* Load font directory */
error = sfnt->load_face( stream, face, face_index, num_params, params );
if ( error )
goto Exit;
if ( tt_check_trickyness( ttface ) )
ttface->face_flags |= FT_FACE_FLAG_TRICKY;
error = tt_face_load_hdmx( face, stream );
if ( error )
goto Exit;
if ( FT_IS_SCALABLE( ttface ) )
{
#ifdef FT_CONFIG_OPTION_INCREMENTAL
if ( !ttface->internal->incremental_interface )
#endif
{
error = tt_face_load_loca( face, stream );
/* having a (non-zero) `glyf' table without */
/* a `loca' table is not valid */
if ( face->glyf_len && FT_ERR_EQ( error, Table_Missing ) )
goto Exit;
if ( error )
goto Exit;
}
/* `fpgm', `cvt', and `prep' are optional */
error = tt_face_load_cvt( face, stream );
if ( error && FT_ERR_NEQ( error, Table_Missing ) )
goto Exit;
error = tt_face_load_fpgm( face, stream );
if ( error && FT_ERR_NEQ( error, Table_Missing ) )
goto Exit;
error = tt_face_load_prep( face, stream );
if ( error && FT_ERR_NEQ( error, Table_Missing ) )
goto Exit;
/* Check the scalable flag based on `loca'. */
#ifdef FT_CONFIG_OPTION_INCREMENTAL
if ( !ttface->internal->incremental_interface )
#endif
{
if ( ttface->num_fixed_sizes &&
face->glyph_locations &&
tt_check_single_notdef( ttface ) )
{
FT_TRACE5(( "tt_face_init:"
" Only the `.notdef' glyph has an outline.\n"
" "
" Resetting scalable flag to FALSE.\n" ));
ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE;
}
}
}
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
{
FT_Int instance_index = face_index >> 16;
if ( FT_HAS_MULTIPLE_MASTERS( ttface ) &&
instance_index > 0 )
{
error = TT_Get_MM_Var( face, NULL );
if ( error )
goto Exit;
if ( face->blend->mmvar->namedstyle )
{
FT_Memory memory = ttface->memory;
FT_Var_Named_Style* named_style;
FT_String* style_name;
/* in `face_index', the instance index starts with value 1 */
named_style = face->blend->mmvar->namedstyle + instance_index - 1;
error = sfnt->get_name( face,
(FT_UShort)named_style->strid,
&style_name );
if ( error )
goto Exit;
/* set style name; if already set, replace it */
if ( face->root.style_name )
FT_FREE( face->root.style_name );
face->root.style_name = style_name;
/* finally, select the named instance */
error = TT_Set_Var_Design( face,
face->blend->mmvar->num_axis,
named_style->coords );
if ( error )
goto Exit;
tt_apply_mvar( face );
}
}
}
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
/* initialize standard glyph loading routines */
TT_Init_Glyph_Loading( face );
Exit:
return error;
Bad_Format:
error = FT_THROW( Unknown_File_Format );
goto Exit;
}
|
CWE-787
| 7,513 | 15,539 |
246312310025652996532444890362808382665
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_get_sfnt_checksum( TT_Face face,
FT_UShort i )
{
#if 0 /* if we believe the written value, use following part. */
if ( face->dir_tables[i].CheckSum )
return face->dir_tables[i].CheckSum;
#endif
if ( !face->goto_table )
return 0;
if ( face->goto_table( face,
face->dir_tables[i].Tag,
face->root.stream,
NULL ) )
return 0;
return (FT_ULong)tt_synth_sfnt_checksum( face->root.stream,
face->dir_tables[i].Length );
}
|
CWE-787
| 7,514 | 15,540 |
253128120815564728198956182094149547550
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_glyphzone_done( TT_GlyphZone zone )
{
FT_Memory memory = zone->memory;
if ( memory )
{
FT_FREE( zone->contours );
FT_FREE( zone->tags );
FT_FREE( zone->cur );
FT_FREE( zone->org );
FT_FREE( zone->orus );
zone->max_points = zone->n_points = 0;
zone->max_contours = zone->n_contours = 0;
zone->memory = NULL;
}
}
|
CWE-787
| 7,515 | 15,541 |
29470966861294899082869406530002563932
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_glyphzone_new( FT_Memory memory,
FT_UShort maxPoints,
FT_Short maxContours,
TT_GlyphZone zone )
{
FT_Error error;
FT_ZERO( zone );
zone->memory = memory;
if ( FT_NEW_ARRAY( zone->org, maxPoints ) ||
FT_NEW_ARRAY( zone->cur, maxPoints ) ||
FT_NEW_ARRAY( zone->orus, maxPoints ) ||
FT_NEW_ARRAY( zone->tags, maxPoints ) ||
FT_NEW_ARRAY( zone->contours, maxContours ) )
{
tt_glyphzone_done( zone );
}
else
{
zone->max_points = maxPoints;
zone->max_contours = maxContours;
}
return error;
}
|
CWE-787
| 7,516 | 15,542 |
220356220818232062567170003225756595802
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_size_done( FT_Size ttsize ) /* TT_Size */
{
TT_Size size = (TT_Size)ttsize;
#ifdef TT_USE_BYTECODE_INTERPRETER
tt_size_done_bytecode( ttsize );
#endif
size->ttmetrics.valid = FALSE;
}
|
CWE-787
| 7,517 | 15,543 |
30561980107014400249803419638896202052
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_size_done_bytecode( FT_Size ftsize )
{
TT_Size size = (TT_Size)ftsize;
TT_Face face = (TT_Face)ftsize->face;
FT_Memory memory = face->root.memory;
if ( size->context )
{
TT_Done_Context( size->context );
size->context = NULL;
}
FT_FREE( size->cvt );
size->cvt_size = 0;
/* free storage area */
FT_FREE( size->storage );
size->storage_size = 0;
/* twilight zone */
tt_glyphzone_done( &size->twilight );
FT_FREE( size->function_defs );
FT_FREE( size->instruction_defs );
size->num_function_defs = 0;
size->max_function_defs = 0;
size->num_instruction_defs = 0;
size->max_instruction_defs = 0;
size->max_func = 0;
size->max_ins = 0;
size->bytecode_ready = -1;
size->cvt_ready = -1;
}
|
CWE-787
| 7,518 | 15,544 |
250896423363225532185246298193558934381
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_size_init( FT_Size ttsize ) /* TT_Size */
{
TT_Size size = (TT_Size)ttsize;
FT_Error error = FT_Err_Ok;
#ifdef TT_USE_BYTECODE_INTERPRETER
size->bytecode_ready = -1;
size->cvt_ready = -1;
#endif
size->ttmetrics.valid = FALSE;
size->strike_index = 0xFFFFFFFFUL;
return error;
}
|
CWE-787
| 7,519 | 15,545 |
31415479605751604049423454730473929873
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_size_init_bytecode( FT_Size ftsize,
FT_Bool pedantic )
{
FT_Error error;
TT_Size size = (TT_Size)ftsize;
TT_Face face = (TT_Face)ftsize->face;
FT_Memory memory = face->root.memory;
FT_UShort n_twilight;
TT_MaxProfile* maxp = &face->max_profile;
/* clean up bytecode related data */
FT_FREE( size->function_defs );
FT_FREE( size->instruction_defs );
FT_FREE( size->cvt );
FT_FREE( size->storage );
if ( size->context )
TT_Done_Context( size->context );
tt_glyphzone_done( &size->twilight );
size->bytecode_ready = -1;
size->cvt_ready = -1;
size->context = TT_New_Context( (TT_Driver)face->root.driver );
size->max_function_defs = maxp->maxFunctionDefs;
size->max_instruction_defs = maxp->maxInstructionDefs;
size->num_function_defs = 0;
size->num_instruction_defs = 0;
size->max_func = 0;
size->max_ins = 0;
size->cvt_size = face->cvt_size;
size->storage_size = maxp->maxStorage;
/* Set default metrics */
{
TT_Size_Metrics* metrics = &size->ttmetrics;
metrics->rotated = FALSE;
metrics->stretched = FALSE;
/* set default engine compensation */
metrics->compensations[0] = 0; /* gray */
metrics->compensations[1] = 0; /* black */
metrics->compensations[2] = 0; /* white */
metrics->compensations[3] = 0; /* reserved */
}
/* allocate function defs, instruction defs, cvt, and storage area */
if ( FT_NEW_ARRAY( size->function_defs, size->max_function_defs ) ||
FT_NEW_ARRAY( size->instruction_defs, size->max_instruction_defs ) ||
FT_NEW_ARRAY( size->cvt, size->cvt_size ) ||
FT_NEW_ARRAY( size->storage, size->storage_size ) )
goto Exit;
/* reserve twilight zone */
n_twilight = maxp->maxTwilightPoints;
/* there are 4 phantom points (do we need this?) */
n_twilight += 4;
error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight );
if ( error )
goto Exit;
size->twilight.n_points = n_twilight;
size->GS = tt_default_graphics_state;
/* set `face->interpreter' according to the debug hook present */
{
FT_Library library = face->root.driver->root.library;
face->interpreter = (TT_Interpreter)
library->debug_hooks[FT_DEBUG_HOOK_TRUETYPE];
if ( !face->interpreter )
face->interpreter = (TT_Interpreter)TT_RunIns;
}
/* Fine, now run the font program! */
/* In case of an error while executing `fpgm', we intentionally don't */
/* clean up immediately – bugs in the `fpgm' are so fundamental that */
/* all following hinting calls should fail. Additionally, `fpgm' is */
/* to be executed just once; calling it again is completely useless */
/* and might even lead to extremely slow behaviour if it is malformed */
/* (containing an infinite loop, for example). */
error = tt_size_run_fpgm( size, pedantic );
return error;
Exit:
if ( error )
tt_size_done_bytecode( ftsize );
return error;
}
|
CWE-787
| 7,520 | 15,546 |
310436048850122197809132314592262982725
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_size_ready_bytecode( TT_Size size,
FT_Bool pedantic )
{
FT_Error error = FT_Err_Ok;
if ( size->bytecode_ready < 0 )
error = tt_size_init_bytecode( (FT_Size)size, pedantic );
else
error = size->bytecode_ready;
if ( error )
goto Exit;
/* rescale CVT when needed */
if ( size->cvt_ready < 0 )
{
FT_UInt i;
TT_Face face = (TT_Face)size->root.face;
/* Scale the cvt values to the new ppem. */
/* We use by default the y ppem to scale the CVT. */
for ( i = 0; i < size->cvt_size; i++ )
size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
/* all twilight points are originally zero */
for ( i = 0; i < (FT_UInt)size->twilight.n_points; i++ )
{
size->twilight.org[i].x = 0;
size->twilight.org[i].y = 0;
size->twilight.cur[i].x = 0;
size->twilight.cur[i].y = 0;
}
/* clear storage area */
for ( i = 0; i < (FT_UInt)size->storage_size; i++ )
size->storage[i] = 0;
size->GS = tt_default_graphics_state;
error = tt_size_run_prep( size, pedantic );
}
else
error = size->cvt_ready;
Exit:
return error;
}
|
CWE-787
| 7,521 | 15,547 |
172121751129836470742145545290761283214
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_size_run_prep( TT_Size size,
FT_Bool pedantic )
{
TT_Face face = (TT_Face)size->root.face;
TT_ExecContext exec;
FT_Error error;
exec = size->context;
error = TT_Load_Context( exec, face, size );
if ( error )
return error;
exec->callTop = 0;
exec->top = 0;
exec->instruction_trap = FALSE;
exec->pedantic_hinting = pedantic;
TT_Set_CodeRange( exec,
tt_coderange_cvt,
face->cvt_program,
(FT_Long)face->cvt_program_size );
TT_Clear_CodeRange( exec, tt_coderange_glyph );
if ( face->cvt_program_size > 0 )
{
TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
FT_TRACE4(( "Executing `prep' table.\n" ));
error = face->interpreter( exec );
#ifdef FT_DEBUG_LEVEL_TRACE
if ( error )
FT_TRACE4(( " interpretation failed with error code 0x%x\n",
error ));
#endif
}
else
error = FT_Err_Ok;
size->cvt_ready = error;
/* UNDOCUMENTED! The MS rasterizer doesn't allow the following */
/* graphics state variables to be modified by the CVT program. */
exec->GS.dualVector.x = 0x4000;
exec->GS.dualVector.y = 0;
exec->GS.projVector.x = 0x4000;
exec->GS.projVector.y = 0x0;
exec->GS.freeVector.x = 0x4000;
exec->GS.freeVector.y = 0x0;
exec->GS.rp0 = 0;
exec->GS.rp1 = 0;
exec->GS.rp2 = 0;
exec->GS.gep0 = 1;
exec->GS.gep1 = 1;
exec->GS.gep2 = 1;
exec->GS.loop = 1;
/* save as default graphics state */
size->GS = exec->GS;
TT_Save_Context( exec, size );
return error;
}
|
CWE-787
| 7,523 | 15,548 |
311610091980007433762241499203595320523
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_slot_init( FT_GlyphSlot slot )
{
return FT_GlyphLoader_CreateExtra( slot->internal->loader );
}
|
CWE-787
| 7,524 | 15,549 |
233481868640895067700913117356762751945
| null | null | null |
savannah
|
e6699596af5c5d6f0ae0ea06e19df87dce088df8
| 0 |
tt_synth_sfnt_checksum( FT_Stream stream,
FT_ULong length )
{
FT_Error error;
FT_UInt32 checksum = 0;
FT_UInt i;
if ( FT_FRAME_ENTER( length ) )
return 0;
for ( ; length > 3; length -= 4 )
checksum += (FT_UInt32)FT_GET_ULONG();
for ( i = 3; length > 0; length--, i-- )
checksum += (FT_UInt32)FT_GET_BYTE() << ( i * 8 );
FT_FRAME_EXIT();
return checksum;
}
|
CWE-787
| 7,525 | 15,550 |
165314016859838747350303102994348978102
| null | null | null |
savannah
|
7bbb91fbf47fc0775cc9705673caf0c47a81f94b
| 0 |
sfnt_done_face( TT_Face face )
{
FT_Memory memory;
SFNT_Service sfnt;
if ( !face )
return;
memory = face->root.memory;
sfnt = (SFNT_Service)face->sfnt;
if ( sfnt )
{
/* destroy the postscript names table if it is loaded */
if ( sfnt->free_psnames )
sfnt->free_psnames( face );
/* destroy the embedded bitmaps table if it is loaded */
if ( sfnt->free_eblc )
sfnt->free_eblc( face );
}
#ifdef TT_CONFIG_OPTION_BDF
/* freeing the embedded BDF properties */
tt_face_free_bdf_props( face );
#endif
/* freeing the kerning table */
tt_face_done_kern( face );
/* freeing the collection table */
FT_FREE( face->ttc_header.offsets );
face->ttc_header.count = 0;
/* freeing table directory */
FT_FREE( face->dir_tables );
face->num_tables = 0;
{
FT_Stream stream = FT_FACE_STREAM( face );
/* simply release the 'cmap' table frame */
FT_FRAME_RELEASE( face->cmap_table );
face->cmap_size = 0;
}
face->horz_metrics_size = 0;
face->vert_metrics_size = 0;
/* freeing vertical metrics, if any */
if ( face->vertical_info )
{
FT_FREE( face->vertical.long_metrics );
FT_FREE( face->vertical.short_metrics );
face->vertical_info = 0;
}
/* freeing the gasp table */
FT_FREE( face->gasp.gaspRanges );
face->gasp.numRanges = 0;
/* freeing the name table */
if ( sfnt )
sfnt->free_name( face );
/* freeing family and style name */
FT_FREE( face->root.family_name );
FT_FREE( face->root.style_name );
/* freeing sbit size table */
FT_FREE( face->root.available_sizes );
FT_FREE( face->sbit_strike_map );
face->root.num_fixed_sizes = 0;
FT_FREE( face->postscript_name );
face->sfnt = NULL;
}
|
CWE-787
| 7,531 | 15,555 |
276230625961489502349667621187630722758
| null | null | null |
savannah
|
7bbb91fbf47fc0775cc9705673caf0c47a81f94b
| 0 |
sfnt_load_face( FT_Stream stream,
TT_Face face,
FT_Int face_instance_index,
FT_Int num_params,
FT_Parameter* params )
{
FT_Error error;
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
FT_Error psnames_error;
#endif
FT_Bool has_outline;
FT_Bool is_apple_sbit;
FT_Bool is_apple_sbix;
FT_Bool ignore_typographic_family = FALSE;
FT_Bool ignore_typographic_subfamily = FALSE;
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
FT_UNUSED( face_instance_index );
/* Check parameters */
{
FT_Int i;
for ( i = 0; i < num_params; i++ )
{
if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY )
ignore_typographic_family = TRUE;
else if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY )
ignore_typographic_subfamily = TRUE;
}
}
/* Load tables */
/* We now support two SFNT-based bitmapped font formats. They */
/* are recognized easily as they do not include a `glyf' */
/* table. */
/* */
/* The first format comes from Apple, and uses a table named */
/* `bhed' instead of `head' to store the font header (using */
/* the same format). It also doesn't include horizontal and */
/* vertical metrics tables (i.e. `hhea' and `vhea' tables are */
/* missing). */
/* */
/* The other format comes from Microsoft, and is used with */
/* WinCE/PocketPC. It looks like a standard TTF, except that */
/* it doesn't contain outlines. */
/* */
FT_TRACE2(( "sfnt_load_face: %08p\n\n", face ));
/* do we have outlines in there? */
#ifdef FT_CONFIG_OPTION_INCREMENTAL
has_outline = FT_BOOL( face->root.internal->incremental_interface ||
tt_face_lookup_table( face, TTAG_glyf ) ||
tt_face_lookup_table( face, TTAG_CFF ) ||
tt_face_lookup_table( face, TTAG_CFF2 ) );
#else
has_outline = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) ||
tt_face_lookup_table( face, TTAG_CFF ) ||
tt_face_lookup_table( face, TTAG_CFF2 ) );
#endif
is_apple_sbit = 0;
is_apple_sbix = !face->goto_table( face, TTAG_sbix, stream, 0 );
/* Apple 'sbix' color bitmaps are rendered scaled and then the 'glyf'
* outline rendered on top. We don't support that yet, so just ignore
* the 'glyf' outline and advertise it as a bitmap-only font. */
if ( is_apple_sbix )
has_outline = FALSE;
/* if this font doesn't contain outlines, we try to load */
/* a `bhed' table */
if ( !has_outline && sfnt->load_bhed )
{
LOAD_( bhed );
is_apple_sbit = FT_BOOL( !error );
}
/* load the font header (`head' table) if this isn't an Apple */
/* sbit font file */
if ( !is_apple_sbit || is_apple_sbix )
{
LOAD_( head );
if ( error )
goto Exit;
}
if ( face->header.Units_Per_EM == 0 )
{
error = FT_THROW( Invalid_Table );
goto Exit;
}
/* the following tables are often not present in embedded TrueType */
/* fonts within PDF documents, so don't check for them. */
LOAD_( maxp );
LOAD_( cmap );
/* the following tables are optional in PCL fonts -- */
/* don't check for errors */
LOAD_( name );
LOAD_( post );
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
psnames_error = error;
#endif
/* do not load the metrics headers and tables if this is an Apple */
/* sbit font file */
if ( !is_apple_sbit )
{
/* load the `hhea' and `hmtx' tables */
LOADM_( hhea, 0 );
if ( !error )
{
LOADM_( hmtx, 0 );
if ( FT_ERR_EQ( error, Table_Missing ) )
{
error = FT_THROW( Hmtx_Table_Missing );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* If this is an incrementally loaded font and there are */
/* overriding metrics, tolerate a missing `hmtx' table. */
if ( face->root.internal->incremental_interface &&
face->root.internal->incremental_interface->funcs->
get_glyph_metrics )
{
face->horizontal.number_Of_HMetrics = 0;
error = FT_Err_Ok;
}
#endif
}
}
else if ( FT_ERR_EQ( error, Table_Missing ) )
{
/* No `hhea' table necessary for SFNT Mac fonts. */
if ( face->format_tag == TTAG_true )
{
FT_TRACE2(( "This is an SFNT Mac font.\n" ));
has_outline = 0;
error = FT_Err_Ok;
}
else
{
error = FT_THROW( Horiz_Header_Missing );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* If this is an incrementally loaded font and there are */
/* overriding metrics, tolerate a missing `hhea' table. */
if ( face->root.internal->incremental_interface &&
face->root.internal->incremental_interface->funcs->
get_glyph_metrics )
{
face->horizontal.number_Of_HMetrics = 0;
error = FT_Err_Ok;
}
#endif
}
}
if ( error )
goto Exit;
/* try to load the `vhea' and `vmtx' tables */
LOADM_( hhea, 1 );
if ( !error )
{
LOADM_( hmtx, 1 );
if ( !error )
face->vertical_info = 1;
}
if ( error && FT_ERR_NEQ( error, Table_Missing ) )
goto Exit;
LOAD_( os2 );
if ( error )
{
/* we treat the table as missing if there are any errors */
face->os2.version = 0xFFFFU;
}
}
/* the optional tables */
/* embedded bitmap support */
if ( sfnt->load_eblc )
LOAD_( eblc );
/* consider the pclt, kerning, and gasp tables as optional */
LOAD_( pclt );
LOAD_( gasp );
LOAD_( kern );
face->root.num_glyphs = face->max_profile.numGlyphs;
/* Bit 8 of the `fsSelection' field in the `OS/2' table denotes */
/* a WWS-only font face. `WWS' stands for `weight', width', and */
/* `slope', a term used by Microsoft's Windows Presentation */
/* Foundation (WPF). This flag has been introduced in version */
/* 1.5 of the OpenType specification (May 2008). */
face->root.family_name = NULL;
face->root.style_name = NULL;
if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 )
{
if ( !ignore_typographic_family )
GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name );
if ( !face->root.family_name )
GET_NAME( FONT_FAMILY, &face->root.family_name );
if ( !ignore_typographic_subfamily )
GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name );
if ( !face->root.style_name )
GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
}
else
{
GET_NAME( WWS_FAMILY, &face->root.family_name );
if ( !face->root.family_name && !ignore_typographic_family )
GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name );
if ( !face->root.family_name )
GET_NAME( FONT_FAMILY, &face->root.family_name );
GET_NAME( WWS_SUBFAMILY, &face->root.style_name );
if ( !face->root.style_name && !ignore_typographic_subfamily )
GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name );
if ( !face->root.style_name )
GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
}
/* now set up root fields */
{
FT_Face root = &face->root;
FT_Long flags = root->face_flags;
/*********************************************************************/
/* */
/* Compute face flags. */
/* */
if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_CBLC ||
face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX )
flags |= FT_FACE_FLAG_COLOR; /* color glyphs */
if ( has_outline == TRUE )
flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */
/* The sfnt driver only supports bitmap fonts natively, thus we */
/* don't set FT_FACE_FLAG_HINTER. */
flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */
FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
if ( !psnames_error &&
face->postscript.FormatType != 0x00030000L )
flags |= FT_FACE_FLAG_GLYPH_NAMES;
#endif
/* fixed width font? */
if ( face->postscript.isFixedPitch )
flags |= FT_FACE_FLAG_FIXED_WIDTH;
/* vertical information? */
if ( face->vertical_info )
flags |= FT_FACE_FLAG_VERTICAL;
/* kerning available ? */
if ( TT_FACE_HAS_KERNING( face ) )
flags |= FT_FACE_FLAG_KERNING;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/* Don't bother to load the tables unless somebody asks for them. */
/* No need to do work which will (probably) not be used. */
if ( face->variation_support & TT_FACE_FLAG_VAR_FVAR )
{
if ( tt_face_lookup_table( face, TTAG_glyf ) != 0 &&
tt_face_lookup_table( face, TTAG_gvar ) != 0 )
flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
if ( tt_face_lookup_table( face, TTAG_CFF2 ) != 0 )
flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
}
#endif
root->face_flags = flags;
/*********************************************************************/
/* */
/* Compute style flags. */
/* */
flags = 0;
if ( has_outline == TRUE && face->os2.version != 0xFFFFU )
{
/* We have an OS/2 table; use the `fsSelection' field. Bit 9 */
/* indicates an oblique font face. This flag has been */
/* introduced in version 1.5 of the OpenType specification. */
if ( face->os2.fsSelection & 512 ) /* bit 9 */
flags |= FT_STYLE_FLAG_ITALIC;
else if ( face->os2.fsSelection & 1 ) /* bit 0 */
flags |= FT_STYLE_FLAG_ITALIC;
if ( face->os2.fsSelection & 32 ) /* bit 5 */
flags |= FT_STYLE_FLAG_BOLD;
}
else
{
/* this is an old Mac font, use the header field */
if ( face->header.Mac_Style & 1 )
flags |= FT_STYLE_FLAG_BOLD;
if ( face->header.Mac_Style & 2 )
flags |= FT_STYLE_FLAG_ITALIC;
}
root->style_flags |= flags;
/*********************************************************************/
/* */
/* Polish the charmaps. */
/* */
/* Try to set the charmap encoding according to the platform & */
/* encoding ID of each charmap. */
/* */
tt_face_build_cmaps( face ); /* ignore errors */
/* set the encoding fields */
{
FT_Int m;
for ( m = 0; m < root->num_charmaps; m++ )
{
FT_CharMap charmap = root->charmaps[m];
charmap->encoding = sfnt_find_encoding( charmap->platform_id,
charmap->encoding_id );
#if 0
if ( !root->charmap &&
charmap->encoding == FT_ENCODING_UNICODE )
{
/* set 'root->charmap' to the first Unicode encoding we find */
root->charmap = charmap;
}
#endif
}
}
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
/*
* Now allocate the root array of FT_Bitmap_Size records and
* populate them. Unfortunately, it isn't possible to indicate bit
* depths in the FT_Bitmap_Size record. This is a design error.
*/
{
FT_UInt count;
count = face->sbit_num_strikes;
if ( count > 0 )
{
FT_Memory memory = face->root.stream->memory;
FT_UShort em_size = face->header.Units_Per_EM;
FT_Short avgwidth = face->os2.xAvgCharWidth;
FT_Size_Metrics metrics;
FT_UInt* sbit_strike_map = NULL;
FT_UInt strike_idx, bsize_idx;
if ( em_size == 0 || face->os2.version == 0xFFFFU )
{
avgwidth = 1;
em_size = 1;
}
/* to avoid invalid strike data in the `available_sizes' field */
/* of `FT_Face', we map `available_sizes' indices to strike */
/* indices */
if ( FT_NEW_ARRAY( root->available_sizes, count ) ||
FT_NEW_ARRAY( sbit_strike_map, count ) )
goto Exit;
bsize_idx = 0;
for ( strike_idx = 0; strike_idx < count; strike_idx++ )
{
FT_Bitmap_Size* bsize = root->available_sizes + bsize_idx;
error = sfnt->load_strike_metrics( face, strike_idx, &metrics );
if ( error )
continue;
bsize->height = (FT_Short)( metrics.height >> 6 );
bsize->width = (FT_Short)(
( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size );
bsize->x_ppem = metrics.x_ppem << 6;
bsize->y_ppem = metrics.y_ppem << 6;
/* assume 72dpi */
bsize->size = metrics.y_ppem << 6;
/* only use strikes with valid PPEM values */
if ( bsize->x_ppem && bsize->y_ppem )
sbit_strike_map[bsize_idx++] = strike_idx;
}
/* reduce array size to the actually used elements */
(void)FT_RENEW_ARRAY( sbit_strike_map, count, bsize_idx );
/* from now on, all strike indices are mapped */
/* using `sbit_strike_map' */
if ( bsize_idx )
{
face->sbit_strike_map = sbit_strike_map;
root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
root->num_fixed_sizes = (FT_Int)bsize_idx;
}
}
}
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
/* a font with no bitmaps and no outlines is scalable; */
/* it has only empty glyphs then */
if ( !FT_HAS_FIXED_SIZES( root ) && !FT_IS_SCALABLE( root ) )
root->face_flags |= FT_FACE_FLAG_SCALABLE;
/*********************************************************************/
/* */
/* Set up metrics. */
/* */
if ( FT_IS_SCALABLE( root ) )
{
/* XXX What about if outline header is missing */
/* (e.g. sfnt wrapped bitmap)? */
root->bbox.xMin = face->header.xMin;
root->bbox.yMin = face->header.yMin;
root->bbox.xMax = face->header.xMax;
root->bbox.yMax = face->header.yMax;
root->units_per_EM = face->header.Units_Per_EM;
/* XXX: Computing the ascender/descender/height is very different */
/* from what the specification tells you. Apparently, we */
/* must be careful because */
/* */
/* - not all fonts have an OS/2 table; in this case, we take */
/* the values in the horizontal header. However, these */
/* values very often are not reliable. */
/* */
/* - otherwise, the correct typographic values are in the */
/* sTypoAscender, sTypoDescender & sTypoLineGap fields. */
/* */
/* However, certain fonts have these fields set to 0. */
/* Rather, they have usWinAscent & usWinDescent correctly */
/* set (but with different values). */
/* */
/* As an example, Arial Narrow is implemented through four */
/* files ARIALN.TTF, ARIALNI.TTF, ARIALNB.TTF & ARIALNBI.TTF */
/* */
/* Strangely, all fonts have the same values in their */
/* sTypoXXX fields, except ARIALNB which sets them to 0. */
/* */
/* On the other hand, they all have different */
/* usWinAscent/Descent values -- as a conclusion, the OS/2 */
/* table cannot be used to compute the text height reliably! */
/* */
/* The ascender and descender are taken from the `hhea' table. */
/* If zero, they are taken from the `OS/2' table. */
root->ascender = face->horizontal.Ascender;
root->descender = face->horizontal.Descender;
root->height = root->ascender - root->descender +
face->horizontal.Line_Gap;
if ( !( root->ascender || root->descender ) )
{
if ( face->os2.version != 0xFFFFU )
{
if ( face->os2.sTypoAscender || face->os2.sTypoDescender )
{
root->ascender = face->os2.sTypoAscender;
root->descender = face->os2.sTypoDescender;
root->height = root->ascender - root->descender +
face->os2.sTypoLineGap;
}
else
{
root->ascender = (FT_Short)face->os2.usWinAscent;
root->descender = -(FT_Short)face->os2.usWinDescent;
root->height = root->ascender - root->descender;
}
}
}
root->max_advance_width =
(FT_Short)face->horizontal.advance_Width_Max;
root->max_advance_height =
(FT_Short)( face->vertical_info ? face->vertical.advance_Height_Max
: root->height );
/* See http://www.microsoft.com/OpenType/OTSpec/post.htm -- */
/* Adjust underline position from top edge to centre of */
/* stroke to convert TrueType meaning to FreeType meaning. */
root->underline_position = face->postscript.underlinePosition -
face->postscript.underlineThickness / 2;
root->underline_thickness = face->postscript.underlineThickness;
}
}
Exit:
FT_TRACE2(( "sfnt_load_face: done\n" ));
return error;
}
|
CWE-787
| 7,532 | 15,556 |
117613725405185399948468116299074741209
| null | null | null |
savannah
|
7bbb91fbf47fc0775cc9705673caf0c47a81f94b
| 0 |
sfnt_open_font( FT_Stream stream,
TT_Face face )
{
FT_Memory memory = stream->memory;
FT_Error error;
FT_ULong tag, offset;
static const FT_Frame_Field ttc_header_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TTC_HeaderRec
FT_FRAME_START( 8 ),
FT_FRAME_LONG( version ),
FT_FRAME_LONG( count ), /* this is ULong in the specs */
FT_FRAME_END
};
face->ttc_header.tag = 0;
face->ttc_header.version = 0;
face->ttc_header.count = 0;
retry:
offset = FT_STREAM_POS();
if ( FT_READ_ULONG( tag ) )
return error;
if ( tag == TTAG_wOFF )
{
FT_TRACE2(( "sfnt_open_font: file is a WOFF; synthesizing SFNT\n" ));
if ( FT_STREAM_SEEK( offset ) )
return error;
error = woff_open_font( stream, face );
if ( error )
return error;
/* Swap out stream and retry! */
stream = face->root.stream;
goto retry;
}
if ( tag != 0x00010000UL &&
tag != TTAG_ttcf &&
tag != TTAG_OTTO &&
tag != TTAG_true &&
tag != TTAG_typ1 &&
tag != 0x00020000UL )
{
FT_TRACE2(( " not a font using the SFNT container format\n" ));
return FT_THROW( Unknown_File_Format );
}
face->ttc_header.tag = TTAG_ttcf;
if ( tag == TTAG_ttcf )
{
FT_Int n;
FT_TRACE3(( "sfnt_open_font: file is a collection\n" ));
if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) )
return error;
FT_TRACE3(( " with %ld subfonts\n",
face->ttc_header.count ));
if ( face->ttc_header.count == 0 )
return FT_THROW( Invalid_Table );
/* a rough size estimate: let's conservatively assume that there */
/* is just a single table info in each subfont header (12 + 16*1 = */
/* 28 bytes), thus we have (at least) `12 + 4*count' bytes for the */
/* size of the TTC header plus `28*count' bytes for all subfont */
/* headers */
if ( (FT_ULong)face->ttc_header.count > stream->size / ( 28 + 4 ) )
return FT_THROW( Array_Too_Large );
/* now read the offsets of each font in the file */
if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) )
return error;
if ( FT_FRAME_ENTER( face->ttc_header.count * 4L ) )
return error;
for ( n = 0; n < face->ttc_header.count; n++ )
face->ttc_header.offsets[n] = FT_GET_ULONG();
FT_FRAME_EXIT();
}
else
{
FT_TRACE3(( "sfnt_open_font: synthesize TTC\n" ));
face->ttc_header.version = 1 << 16;
face->ttc_header.count = 1;
if ( FT_NEW( face->ttc_header.offsets ) )
return error;
face->ttc_header.offsets[0] = offset;
}
return error;
}
|
CWE-787
| 7,533 | 15,557 |
105471100932118190732110678422981620014
| null | null | null |
poppler
|
5c9b08a875b07853be6c44e43ff5f7f059df666a
| 0 |
void doMergeNameTree(PDFDoc *doc, XRef *srcXRef, XRef *countRef, int oldRefNum, int newRefNum, Dict *srcNameTree, Dict *mergeNameTree, int numOffset) {
Object mergeNameArray;
Object srcNameArray;
mergeNameTree->lookup("Names", &mergeNameArray);
srcNameTree->lookup("Names", &srcNameArray);
if (mergeNameArray.isArray() && srcNameArray.isArray()) {
Object *newNameArray = new Object();
newNameArray->initArray(srcXRef);
int j = 0;
for (int i = 0; i < srcNameArray.arrayGetLength() - 1; i += 2) {
Object key;
Object value;
srcNameArray.arrayGetNF(i, &key);
srcNameArray.arrayGetNF(i + 1, &value);
if (key.isString() && value.isRef()) {
while (j < mergeNameArray.arrayGetLength() - 1) {
Object mkey;
Object mvalue;
mergeNameArray.arrayGetNF(j, &mkey);
mergeNameArray.arrayGetNF(j + 1, &mvalue);
if (mkey.isString() && mvalue.isRef()) {
if (mkey.getString()->cmp(key.getString()) < 0) {
Object *newKey = new Object();
newKey->initString(new GooString(mkey.getString()->getCString()));
newNameArray->arrayAdd(newKey);
Object *newValue = new Object();
newValue->initRef(mvalue.getRef().num + numOffset, mvalue.getRef().gen);
newNameArray->arrayAdd(newValue);
delete newKey;
delete newValue;
j += 2;
} else if (mkey.getString()->cmp(key.getString()) == 0) {
j += 2;
} else {
mkey.free();
mvalue.free();
break;
}
} else {
j += 2;
}
mkey.free();
mvalue.free();
}
Object *newKey = new Object();
newKey->initString(new GooString(key.getString()->getCString()));
newNameArray->arrayAdd(newKey);
Object *newValue = new Object();
newValue->initRef(value.getRef().num, value.getRef().gen);
newNameArray->arrayAdd(newValue);
delete newKey;
delete newValue;
}
key.free();
value.free();
}
while (j < mergeNameArray.arrayGetLength() - 1) {
Object mkey;
Object mvalue;
mergeNameArray.arrayGetNF(j, &mkey);
mergeNameArray.arrayGetNF(j + 1, &mvalue);
if (mkey.isString() && mvalue.isRef()) {
Object *newKey = new Object();
newKey->initString(new GooString(mkey.getString()->getCString()));
newNameArray->arrayAdd(newKey);
Object *newValue = new Object();
newValue->initRef(mvalue.getRef().num + numOffset, mvalue.getRef().gen);
newNameArray->arrayAdd(newValue);
delete newKey;
delete newValue;
}
j += 2;
mkey.free();
mvalue.free();
}
srcNameTree->set("Names", newNameArray);
doc->markPageObjects(mergeNameTree, srcXRef, countRef, numOffset, oldRefNum, newRefNum);
delete newNameArray;
} else if (srcNameArray.isNull() && mergeNameArray.isArray()) {
Object *newNameArray = new Object();
newNameArray->initArray(srcXRef);
for (int i = 0; i < mergeNameArray.arrayGetLength() - 1; i += 2) {
Object key;
Object value;
mergeNameArray.arrayGetNF(i, &key);
mergeNameArray.arrayGetNF(i + 1, &value);
if (key.isString() && value.isRef()) {
Object *newKey = new Object();
newKey->initString(new GooString(key.getString()->getCString()));
newNameArray->arrayAdd(newKey);
Object *newValue = new Object();
newValue->initRef(value.getRef().num + numOffset, value.getRef().gen);
newNameArray->arrayAdd(newValue);
delete newKey;
delete newValue;
}
key.free();
value.free();
}
srcNameTree->add(copyString("Names"), newNameArray);
doc->markPageObjects(mergeNameTree, srcXRef, countRef, numOffset, oldRefNum, newRefNum);
}
mergeNameArray.free();
srcNameArray.free();
}
|
CWE-476
| 7,536 | 15,558 |
70417288352661635019654563879654789328
| null | null | null |
savannah
|
94e01571507835ff59dd8ce2a0b56a4b566965a4
| 0 |
change_env (timezone_t tz)
{
if (setenv_TZ (tz->tz_is_set ? tz->abbrs : NULL) != 0)
return false;
tzset ();
return true;
}
|
CWE-119
| 7,537 | 15,559 |
215518875153710228118807553710712279244
| null | null | null |
savannah
|
94e01571507835ff59dd8ce2a0b56a4b566965a4
| 0 |
equal_tm (const struct tm *a, const struct tm *b)
{
return ! ((a->tm_sec ^ b->tm_sec)
| (a->tm_min ^ b->tm_min)
| (a->tm_hour ^ b->tm_hour)
| (a->tm_mday ^ b->tm_mday)
| (a->tm_mon ^ b->tm_mon)
| (a->tm_year ^ b->tm_year)
| isdst_differ (a->tm_isdst, b->tm_isdst));
}
|
CWE-119
| 7,538 | 15,560 |
100705252028043493140681390905782271368
| null | null | null |
savannah
|
94e01571507835ff59dd8ce2a0b56a4b566965a4
| 0 |
extend_abbrs (char *abbrs, char const *abbr, size_t abbr_size)
{
memcpy (abbrs, abbr, abbr_size);
abbrs[abbr_size] = '\0';
}
|
CWE-119
| 7,539 | 15,561 |
151831173628036125772334746025732490324
| null | null | null |
savannah
|
94e01571507835ff59dd8ce2a0b56a4b566965a4
| 0 |
getenv_TZ (void)
{
return getenv ("TZ");
}
|
CWE-119
| 7,540 | 15,562 |
55284647845019113509759273304266111183
| null | null | null |
savannah
|
94e01571507835ff59dd8ce2a0b56a4b566965a4
| 0 |
isdst_differ (int a, int b)
{
return !a != !b && 0 <= a && 0 <= b;
}
|
CWE-119
| 7,541 | 15,563 |
27676863047836797511677169437433518081
| null | null | null |
savannah
|
94e01571507835ff59dd8ce2a0b56a4b566965a4
| 0 |
localtime_rz (timezone_t tz, time_t const *t, struct tm *tm)
{
if (!tz)
return gmtime_r (t, tm);
else
{
timezone_t old_tz = set_tz (tz);
if (old_tz)
{
bool abbr_saved = localtime_r (t, tm) && save_abbr (tz, tm);
if (revert_tz (old_tz) && abbr_saved)
return tm;
}
return NULL;
}
}
|
CWE-119
| 7,542 | 15,564 |
330317650967974930191709060020247485600
| null | null | null |
savannah
|
94e01571507835ff59dd8ce2a0b56a4b566965a4
| 0 |
mktime_z (timezone_t tz, struct tm *tm)
{
if (!tz)
return timegm (tm);
else
{
timezone_t old_tz = set_tz (tz);
if (old_tz)
{
time_t t = mktime (tm);
#if HAVE_TM_ZONE || HAVE_TZNAME
time_t badtime = -1;
struct tm tm_1;
if ((t != badtime
|| (localtime_r (&t, &tm_1) && equal_tm (tm, &tm_1)))
&& !save_abbr (tz, tm))
t = badtime;
#endif
if (revert_tz (old_tz))
return t;
}
return -1;
}
}
|
CWE-119
| 7,543 | 15,565 |
292658228692525616294596465540887711988
| null | null | null |
savannah
|
94e01571507835ff59dd8ce2a0b56a4b566965a4
| 0 |
revert_tz (timezone_t tz)
{
if (tz == local_tz)
return true;
else
{
int saved_errno = errno;
bool ok = change_env (tz);
if (!ok)
saved_errno = errno;
tzfree (tz);
errno = saved_errno;
return ok;
}
}
|
CWE-119
| 7,544 | 15,566 |
93310548443339644734208689167389211594
| null | null | null |
savannah
|
94e01571507835ff59dd8ce2a0b56a4b566965a4
| 0 |
gmt_offset (time_t s)
{
long gmtoff;
#if !HAVE_TM_GMTOFF
struct tm tm_local = *localtime (&s);
struct tm tm_gmt = *gmtime (&s);
gmtoff = tm_diff (&tm_local, &tm_gmt);
#else
gmtoff = localtime (&s)->tm_gmtoff;
#endif
return gmtoff;
}
|
CWE-119
| 7,545 | 15,567 |
177194573240600358088830486160503231728
| null | null | null |
savannah
|
94e01571507835ff59dd8ce2a0b56a4b566965a4
| 0 |
tm_diff (struct tm const *a, struct tm const *b)
{
/* Compute intervening leap days correctly even if year is negative.
Take care to avoid int overflow in leap day calculations. */
int a4 = SHR (a->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (a->tm_year & 3);
int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3);
int a100 = a4 / 25 - (a4 % 25 < 0);
int b100 = b4 / 25 - (b4 % 25 < 0);
int a400 = SHR (a100, 2);
int b400 = SHR (b100, 2);
int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
long int ayear = a->tm_year;
long int years = ayear - b->tm_year;
long int days = (365 * years + intervening_leap_days
+ (a->tm_yday - b->tm_yday));
return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
+ (a->tm_min - b->tm_min))
+ (a->tm_sec - b->tm_sec));
}
|
CWE-119
| 7,546 | 15,568 |
185114128456390506095648740733721536282
| null | null | null |
savannah
|
59eb9f8cfe7d1df379a2318316d1f04f80fba54a
| 0 |
TT_Get_MM_Var( TT_Face face,
FT_MM_Var* *master )
{
FT_Stream stream = face->root.stream;
FT_Memory memory = face->root.memory;
FT_ULong table_len;
FT_Error error = TT_Err_Ok;
FT_ULong fvar_start;
FT_Int i, j;
FT_MM_Var* mmvar;
FT_Fixed* next_coords;
FT_String* next_name;
FT_Var_Axis* a;
FT_Var_Named_Style* ns;
GX_FVar_Head fvar_head;
static const FT_Frame_Field fvar_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE GX_FVar_Head
FT_FRAME_START( 16 ),
FT_FRAME_LONG ( version ),
FT_FRAME_USHORT( offsetToData ),
FT_FRAME_USHORT( countSizePairs ),
FT_FRAME_USHORT( axisCount ),
FT_FRAME_USHORT( axisSize ),
FT_FRAME_USHORT( instanceCount ),
FT_FRAME_USHORT( instanceSize ),
FT_FRAME_END
};
static const FT_Frame_Field fvaraxis_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE GX_FVar_Axis
FT_FRAME_START( 20 ),
FT_FRAME_ULONG ( axisTag ),
FT_FRAME_ULONG ( minValue ),
FT_FRAME_ULONG ( defaultValue ),
FT_FRAME_ULONG ( maxValue ),
FT_FRAME_USHORT( flags ),
FT_FRAME_USHORT( nameID ),
FT_FRAME_END
};
if ( face->blend == NULL )
{
/* both `fvar' and `gvar' must be present */
if ( (error = face->goto_table( face, TTAG_gvar,
stream, &table_len )) != 0 )
goto Exit;
if ( (error = face->goto_table( face, TTAG_fvar,
stream, &table_len )) != 0 )
goto Exit;
fvar_start = FT_STREAM_POS( );
if ( FT_STREAM_READ_FIELDS( fvar_fields, &fvar_head ) )
goto Exit;
if ( fvar_head.version != (FT_Long)0x00010000L ||
fvar_head.countSizePairs != 2 ||
fvar_head.axisSize != 20 ||
/* axisCount limit implied by 16-bit instanceSize */
fvar_head.axisCount > 0x3FFE ||
fvar_head.instanceSize != 4 + 4 * fvar_head.axisCount ||
/* instanceCount limit implied by limited range of name IDs */
fvar_head.instanceCount > 0x7EFF ||
fvar_head.offsetToData + fvar_head.axisCount * 20U +
fvar_head.instanceCount * fvar_head.instanceSize > table_len )
{
error = TT_Err_Invalid_Table;
goto Exit;
}
if ( FT_NEW( face->blend ) )
goto Exit;
/* cannot overflow 32-bit arithmetic because of limits above */
face->blend->mmvar_len =
sizeof ( FT_MM_Var ) +
fvar_head.axisCount * sizeof ( FT_Var_Axis ) +
fvar_head.instanceCount * sizeof ( FT_Var_Named_Style ) +
fvar_head.instanceCount * fvar_head.axisCount * sizeof ( FT_Fixed ) +
5 * fvar_head.axisCount;
if ( FT_ALLOC( mmvar, face->blend->mmvar_len ) )
goto Exit;
face->blend->mmvar = mmvar;
mmvar->num_axis =
fvar_head.axisCount;
mmvar->num_designs =
(FT_UInt)-1; /* meaningless in this context; each glyph */
/* may have a different number of designs */
/* (or tuples, as called by Apple) */
mmvar->num_namedstyles =
fvar_head.instanceCount;
mmvar->axis =
(FT_Var_Axis*)&(mmvar[1]);
mmvar->namedstyle =
(FT_Var_Named_Style*)&(mmvar->axis[fvar_head.axisCount]);
next_coords =
(FT_Fixed*)&(mmvar->namedstyle[fvar_head.instanceCount]);
for ( i = 0; i < fvar_head.instanceCount; ++i )
{
mmvar->namedstyle[i].coords = next_coords;
next_coords += fvar_head.axisCount;
}
next_name = (FT_String*)next_coords;
for ( i = 0; i < fvar_head.axisCount; ++i )
{
mmvar->axis[i].name = next_name;
next_name += 5;
}
if ( FT_STREAM_SEEK( fvar_start + fvar_head.offsetToData ) )
goto Exit;
a = mmvar->axis;
for ( i = 0; i < fvar_head.axisCount; ++i )
{
GX_FVar_Axis axis_rec;
if ( FT_STREAM_READ_FIELDS( fvaraxis_fields, &axis_rec ) )
goto Exit;
a->tag = axis_rec.axisTag;
a->minimum = axis_rec.minValue; /* A Fixed */
a->def = axis_rec.defaultValue; /* A Fixed */
a->maximum = axis_rec.maxValue; /* A Fixed */
a->strid = axis_rec.nameID;
a->name[0] = (FT_String)( a->tag >> 24 );
a->name[1] = (FT_String)( ( a->tag >> 16 ) & 0xFF );
a->name[2] = (FT_String)( ( a->tag >> 8 ) & 0xFF );
a->name[3] = (FT_String)( ( a->tag ) & 0xFF );
a->name[4] = 0;
++a;
}
ns = mmvar->namedstyle;
for ( i = 0; i < fvar_head.instanceCount; ++i, ++ns )
{
if ( FT_FRAME_ENTER( 4L + 4L * fvar_head.axisCount ) )
goto Exit;
ns->strid = FT_GET_USHORT();
(void) /* flags = */ FT_GET_USHORT();
for ( j = 0; j < fvar_head.axisCount; ++j )
ns->coords[j] = FT_GET_ULONG(); /* A Fixed */
FT_FRAME_EXIT();
}
}
if ( master != NULL )
{
FT_UInt n;
if ( FT_ALLOC( mmvar, face->blend->mmvar_len ) )
goto Exit;
FT_MEM_COPY( mmvar, face->blend->mmvar, face->blend->mmvar_len );
mmvar->axis =
(FT_Var_Axis*)&(mmvar[1]);
mmvar->namedstyle =
(FT_Var_Named_Style*)&(mmvar->axis[mmvar->num_axis]);
next_coords =
(FT_Fixed*)&(mmvar->namedstyle[mmvar->num_namedstyles]);
for ( n = 0; n < mmvar->num_namedstyles; ++n )
{
mmvar->namedstyle[n].coords = next_coords;
next_coords += mmvar->num_axis;
}
a = mmvar->axis;
next_name = (FT_String*)next_coords;
for ( n = 0; n < mmvar->num_axis; ++n )
{
a->name = next_name;
/* standard PostScript names for some standard apple tags */
if ( a->tag == TTAG_wght )
a->name = (char *)"Weight";
else if ( a->tag == TTAG_wdth )
a->name = (char *)"Width";
else if ( a->tag == TTAG_opsz )
a->name = (char *)"OpticalSize";
else if ( a->tag == TTAG_slnt )
a->name = (char *)"Slant";
next_name += 5;
++a;
}
*master = mmvar;
}
Exit:
return error;
}
|
CWE-119
| 7,744 | 15,569 |
330318910453513372695341154109840273523
| null | null | null |
savannah
|
59eb9f8cfe7d1df379a2318316d1f04f80fba54a
| 0 |
TT_Set_MM_Blend( TT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Error error = TT_Err_Ok;
GX_Blend blend;
FT_MM_Var* mmvar;
FT_UInt i;
FT_Memory memory = face->root.memory;
enum
{
mcvt_retain,
mcvt_modify,
mcvt_load
} manageCvt;
face->doblend = FALSE;
if ( face->blend == NULL )
{
if ( (error = TT_Get_MM_Var( face, NULL)) != 0 )
goto Exit;
}
blend = face->blend;
mmvar = blend->mmvar;
if ( num_coords != mmvar->num_axis )
{
error = TT_Err_Invalid_Argument;
goto Exit;
}
for ( i = 0; i < num_coords; ++i )
if ( coords[i] < -0x00010000L || coords[i] > 0x00010000L )
{
error = TT_Err_Invalid_Argument;
goto Exit;
}
if ( blend->glyphoffsets == NULL )
if ( (error = ft_var_load_gvar( face )) != 0 )
goto Exit;
if ( blend->normalizedcoords == NULL )
{
if ( FT_NEW_ARRAY( blend->normalizedcoords, num_coords ) )
goto Exit;
manageCvt = mcvt_modify;
/* If we have not set the blend coordinates before this, then the */
/* cvt table will still be what we read from the `cvt ' table and */
/* we don't need to reload it. We may need to change it though... */
}
else
{
manageCvt = mcvt_retain;
for ( i = 0; i < num_coords; ++i )
{
if ( blend->normalizedcoords[i] != coords[i] )
{
manageCvt = mcvt_load;
break;
}
}
/* If we don't change the blend coords then we don't need to do */
/* anything to the cvt table. It will be correct. Otherwise we */
/* no longer have the original cvt (it was modified when we set */
/* the blend last time), so we must reload and then modify it. */
}
blend->num_axis = num_coords;
FT_MEM_COPY( blend->normalizedcoords,
coords,
num_coords * sizeof ( FT_Fixed ) );
face->doblend = TRUE;
if ( face->cvt != NULL )
{
switch ( manageCvt )
{
case mcvt_load:
/* The cvt table has been loaded already; every time we change the */
/* blend we may need to reload and remodify the cvt table. */
FT_FREE( face->cvt );
face->cvt = NULL;
tt_face_load_cvt( face, face->root.stream );
break;
case mcvt_modify:
/* The original cvt table is in memory. All we need to do is */
/* apply the `cvar' table (if any). */
tt_face_vary_cvt( face, face->root.stream );
break;
case mcvt_retain:
/* The cvt table is correct for this set of coordinates. */
break;
}
}
Exit:
return error;
}
|
CWE-119
| 7,745 | 15,570 |
227994846753005694515060109072647851013
| null | null | null |
savannah
|
59eb9f8cfe7d1df379a2318316d1f04f80fba54a
| 0 |
TT_Set_Var_Design( TT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Error error = TT_Err_Ok;
FT_Fixed* normalized = NULL;
GX_Blend blend;
FT_MM_Var* mmvar;
FT_UInt i, j;
FT_Var_Axis* a;
GX_AVarSegment av;
FT_Memory memory = face->root.memory;
if ( face->blend == NULL )
{
if ( (error = TT_Get_MM_Var( face, NULL )) != 0 )
goto Exit;
}
blend = face->blend;
mmvar = blend->mmvar;
if ( num_coords != mmvar->num_axis )
{
error = TT_Err_Invalid_Argument;
goto Exit;
}
/* Axis normalization is a two stage process. First we normalize */
/* based on the [min,def,max] values for the axis to be [-1,0,1]. */
/* Then, if there's an `avar' table, we renormalize this range. */
if ( FT_NEW_ARRAY( normalized, mmvar->num_axis ) )
goto Exit;
a = mmvar->axis;
for ( i = 0; i < mmvar->num_axis; ++i, ++a )
{
if ( coords[i] > a->maximum || coords[i] < a->minimum )
{
error = TT_Err_Invalid_Argument;
goto Exit;
}
if ( coords[i] < a->def )
{
normalized[i] = -FT_MulDiv( coords[i] - a->def,
0x10000L,
a->minimum - a->def );
}
else if ( a->maximum == a->def )
normalized[i] = 0;
else
{
normalized[i] = FT_MulDiv( coords[i] - a->def,
0x10000L,
a->maximum - a->def );
}
}
if ( !blend->avar_checked )
ft_var_load_avar( face );
if ( blend->avar_segment != NULL )
{
av = blend->avar_segment;
for ( i = 0; i < mmvar->num_axis; ++i, ++av )
{
for ( j = 1; j < (FT_UInt)av->pairCount; ++j )
if ( normalized[i] < av->correspondence[j].fromCoord )
{
normalized[i] =
FT_MulDiv(
FT_MulDiv(
normalized[i] - av->correspondence[j - 1].fromCoord,
0x10000L,
av->correspondence[j].fromCoord -
av->correspondence[j - 1].fromCoord ),
av->correspondence[j].toCoord -
av->correspondence[j - 1].toCoord,
0x10000L ) +
av->correspondence[j - 1].toCoord;
break;
}
}
}
error = TT_Set_MM_Blend( face, num_coords, normalized );
Exit:
FT_FREE( normalized );
return error;
}
|
CWE-119
| 7,746 | 15,571 |
320756258289370506493058436960125691405
| null | null | null |
savannah
|
59eb9f8cfe7d1df379a2318316d1f04f80fba54a
| 0 |
TT_Vary_Get_Glyph_Deltas( TT_Face face,
FT_UInt glyph_index,
FT_Vector* *deltas,
FT_UInt n_points )
{
FT_Stream stream = face->root.stream;
FT_Memory memory = stream->memory;
GX_Blend blend = face->blend;
FT_Vector* delta_xy;
FT_Error error;
FT_ULong glyph_start;
FT_UInt tupleCount;
FT_ULong offsetToData;
FT_ULong here;
FT_UInt i, j;
FT_Fixed* tuple_coords = NULL;
FT_Fixed* im_start_coords = NULL;
FT_Fixed* im_end_coords = NULL;
FT_UInt point_count, spoint_count = 0;
FT_UShort* sharedpoints = NULL;
FT_UShort* localpoints = NULL;
FT_UShort* points;
FT_Short *deltas_x, *deltas_y;
if ( !face->doblend || blend == NULL )
return TT_Err_Invalid_Argument;
/* to be freed by the caller */
if ( FT_NEW_ARRAY( delta_xy, n_points ) )
goto Exit;
*deltas = delta_xy;
if ( glyph_index >= blend->gv_glyphcnt ||
blend->glyphoffsets[glyph_index] ==
blend->glyphoffsets[glyph_index + 1] )
return TT_Err_Ok; /* no variation data for this glyph */
if ( FT_STREAM_SEEK( blend->glyphoffsets[glyph_index] ) ||
FT_FRAME_ENTER( blend->glyphoffsets[glyph_index + 1] -
blend->glyphoffsets[glyph_index] ) )
goto Fail1;
glyph_start = FT_Stream_FTell( stream );
/* each set of glyph variation data is formatted similarly to `cvar' */
/* (except we get shared points and global tuples) */
if ( FT_NEW_ARRAY( tuple_coords, blend->num_axis ) ||
FT_NEW_ARRAY( im_start_coords, blend->num_axis ) ||
FT_NEW_ARRAY( im_end_coords, blend->num_axis ) )
goto Fail2;
tupleCount = FT_GET_USHORT();
offsetToData = glyph_start + FT_GET_USHORT();
if ( tupleCount & GX_TC_TUPLES_SHARE_POINT_NUMBERS )
{
here = FT_Stream_FTell( stream );
FT_Stream_SeekSet( stream, offsetToData );
sharedpoints = ft_var_readpackedpoints( stream, &spoint_count );
offsetToData = FT_Stream_FTell( stream );
FT_Stream_SeekSet( stream, here );
}
for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); ++i )
{
FT_UInt tupleDataSize;
FT_UInt tupleIndex;
FT_Fixed apply;
tupleDataSize = FT_GET_USHORT();
tupleIndex = FT_GET_USHORT();
if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
{
for ( j = 0; j < blend->num_axis; ++j )
tuple_coords[j] = FT_GET_SHORT() << 2; /* convert from */
/* short frac to fixed */
}
else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount )
{
error = TT_Err_Invalid_Table;
goto Fail3;
}
else
{
FT_MEM_COPY(
tuple_coords,
&blend->tuplecoords[(tupleIndex & 0xFFF) * blend->num_axis],
blend->num_axis * sizeof ( FT_Fixed ) );
}
if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
{
for ( j = 0; j < blend->num_axis; ++j )
im_start_coords[j] = FT_GET_SHORT() << 2;
for ( j = 0; j < blend->num_axis; ++j )
im_end_coords[j] = FT_GET_SHORT() << 2;
}
apply = ft_var_apply_tuple( blend,
(FT_UShort)tupleIndex,
tuple_coords,
im_start_coords,
im_end_coords );
if ( apply == 0 ) /* tuple isn't active for our blend */
{
offsetToData += tupleDataSize;
continue;
}
here = FT_Stream_FTell( stream );
if ( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS )
{
FT_Stream_SeekSet( stream, offsetToData );
localpoints = ft_var_readpackedpoints( stream, &point_count );
points = localpoints;
}
else
{
points = sharedpoints;
point_count = spoint_count;
}
deltas_x = ft_var_readpackeddeltas( stream,
point_count == 0 ? n_points
: point_count );
deltas_y = ft_var_readpackeddeltas( stream,
point_count == 0 ? n_points
: point_count );
if ( points == NULL || deltas_y == NULL || deltas_x == NULL )
; /* failure, ignore it */
else if ( points == ALL_POINTS )
{
/* this means that there are deltas for every point in the glyph */
for ( j = 0; j < n_points; ++j )
{
delta_xy[j].x += FT_MulFix( deltas_x[j], apply );
delta_xy[j].y += FT_MulFix( deltas_y[j], apply );
}
}
else
{
for ( j = 0; j < point_count; ++j )
{
delta_xy[localpoints[j]].x += FT_MulFix( deltas_x[j], apply );
delta_xy[localpoints[j]].y += FT_MulFix( deltas_y[j], apply );
}
}
if ( localpoints != ALL_POINTS )
FT_FREE( localpoints );
FT_FREE( deltas_x );
FT_FREE( deltas_y );
offsetToData += tupleDataSize;
FT_Stream_SeekSet( stream, here );
}
Fail3:
FT_FREE( tuple_coords );
FT_FREE( im_start_coords );
FT_FREE( im_end_coords );
Fail2:
FT_FRAME_EXIT();
Fail1:
if ( error )
{
FT_FREE( delta_xy );
*deltas = NULL;
}
Exit:
return error;
}
|
CWE-119
| 7,747 | 15,572 |
207896862780796571096525105196883181249
| null | null | null |
savannah
|
59eb9f8cfe7d1df379a2318316d1f04f80fba54a
| 0 |
ft_var_apply_tuple( GX_Blend blend,
FT_UShort tupleIndex,
FT_Fixed* tuple_coords,
FT_Fixed* im_start_coords,
FT_Fixed* im_end_coords )
{
FT_UInt i;
FT_Fixed apply;
FT_Fixed temp;
apply = 0x10000L;
for ( i = 0; i < blend->num_axis; ++i )
{
if ( tuple_coords[i] == 0 )
/* It's not clear why (for intermediate tuples) we don't need */
/* to check against start/end -- the documentation says we don't. */
/* Similarly, it's unclear why we don't need to scale along the */
/* axis. */
continue;
else if ( blend->normalizedcoords[i] == 0 ||
( blend->normalizedcoords[i] < 0 && tuple_coords[i] > 0 ) ||
( blend->normalizedcoords[i] > 0 && tuple_coords[i] < 0 ) )
{
apply = 0;
break;
}
else if ( !( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) )
/* not an intermediate tuple */
apply = FT_MulDiv( apply,
blend->normalizedcoords[i] > 0
? blend->normalizedcoords[i]
: -blend->normalizedcoords[i],
0x10000L );
else if ( blend->normalizedcoords[i] <= im_start_coords[i] ||
blend->normalizedcoords[i] >= im_end_coords[i] )
{
apply = 0;
break;
}
else if ( blend->normalizedcoords[i] < tuple_coords[i] )
{
temp = FT_MulDiv( blend->normalizedcoords[i] - im_start_coords[i],
0x10000L,
tuple_coords[i] - im_start_coords[i]);
apply = FT_MulDiv( apply, temp, 0x10000L );
}
else
{
temp = FT_MulDiv( im_end_coords[i] - blend->normalizedcoords[i],
0x10000L,
im_end_coords[i] - tuple_coords[i] );
apply = FT_MulDiv( apply, temp, 0x10000L );
}
}
return apply;
}
|
CWE-119
| 7,748 | 15,573 |
256644473243274251395879478133058749934
| null | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.