summaryrefslogtreecommitdiff
path: root/Build/source/libs/freetype2/freetype-src/src/type42/t42parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/freetype2/freetype-src/src/type42/t42parse.c')
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/type42/t42parse.c63
1 files changed, 22 insertions, 41 deletions
diff --git a/Build/source/libs/freetype2/freetype-src/src/type42/t42parse.c b/Build/source/libs/freetype2/freetype-src/src/type42/t42parse.c
index f14b4226c7a..ea2c5198a9d 100644
--- a/Build/source/libs/freetype2/freetype-src/src/type42/t42parse.c
+++ b/Build/source/libs/freetype2/freetype-src/src/type42/t42parse.c
@@ -4,7 +4,7 @@
*
* Type 42 font parser (body).
*
- * Copyright (C) 2002-2022 by
+ * Copyright (C) 2002-2021 by
* Roberto Alameda.
*
* This file is part of the FreeType project, and may only be used,
@@ -363,8 +363,8 @@
/* we use a T1_Table to store our charnames */
loader->num_chars = encode->num_chars = count;
- if ( FT_QNEW_ARRAY( encode->char_index, count ) ||
- FT_QNEW_ARRAY( encode->char_name, count ) ||
+ if ( FT_NEW_ARRAY( encode->char_index, count ) ||
+ FT_NEW_ARRAY( encode->char_name, count ) ||
FT_SET_ERROR( psaux->ps_table_funcs->init(
char_table, count, memory ) ) )
{
@@ -538,8 +538,7 @@
FT_Byte* limit = parser->root.limit;
FT_Error error;
FT_Int num_tables = 0;
- FT_Long ttf_count;
- FT_Long ttf_reserved;
+ FT_Long count;
FT_ULong n, string_size, old_string_size, real_size;
FT_Byte* string_buf = NULL;
@@ -547,9 +546,6 @@
T42_Load_Status status;
- /** There should only be one sfnts array, but free any previous. */
- FT_FREE( face->ttf_data );
- face->ttf_size = 0;
/* The format is */
/* */
@@ -578,10 +574,7 @@
status = BEFORE_START;
string_size = 0;
old_string_size = 0;
- ttf_count = 0;
- ttf_reserved = 12;
- if ( FT_QALLOC( face->ttf_data, ttf_reserved ) )
- goto Fail;
+ count = 0;
FT_TRACE2(( "\n" ));
FT_TRACE2(( "t42_parse_sfnts:\n" ));
@@ -596,7 +589,6 @@
if ( *cur == ']' )
{
parser->root.cursor++;
- face->ttf_size = ttf_count;
goto Exit;
}
@@ -692,7 +684,7 @@
}
FT_TRACE2(( " PS string size %5lu bytes, offset 0x%08lx (%lu)\n",
- string_size, ttf_count, ttf_count ));
+ string_size, count, count ));
/* The whole TTF is now loaded into `string_buf'. We are */
/* checking its contents while copying it to `ttf_data'. */
@@ -705,48 +697,43 @@
{
case BEFORE_START:
/* load offset table, 12 bytes */
- if ( ttf_count < 12 )
+ if ( count < 12 )
{
- face->ttf_data[ttf_count++] = string_buf[n];
+ face->ttf_data[count++] = string_buf[n];
continue;
}
else
{
- FT_Long ttf_reserved_prev = ttf_reserved;
-
-
- num_tables = 16 * face->ttf_data[4] + face->ttf_data[5];
- status = BEFORE_TABLE_DIR;
- ttf_reserved = 12 + 16 * num_tables;
+ num_tables = 16 * face->ttf_data[4] + face->ttf_data[5];
+ status = BEFORE_TABLE_DIR;
+ face->ttf_size = 12 + 16 * num_tables;
FT_TRACE2(( " SFNT directory contains %d tables\n",
num_tables ));
- if ( (FT_Long)size < ttf_reserved )
+ if ( (FT_Long)size < face->ttf_size )
{
FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
- if ( FT_QREALLOC( face->ttf_data, ttf_reserved_prev,
- ttf_reserved ) )
+ if ( FT_QREALLOC( face->ttf_data, 12, face->ttf_size ) )
goto Fail;
}
/* fall through */
case BEFORE_TABLE_DIR:
/* the offset table is read; read the table directory */
- if ( ttf_count < ttf_reserved )
+ if ( count < face->ttf_size )
{
- face->ttf_data[ttf_count++] = string_buf[n];
+ face->ttf_data[count++] = string_buf[n];
continue;
}
else
{
int i;
FT_ULong len;
- FT_Long ttf_reserved_prev = ttf_reserved;
FT_TRACE2(( "\n" ));
@@ -762,7 +749,7 @@
FT_TRACE2(( " %4i 0x%08lx (%lu)\n", i, len, len ));
if ( len > size ||
- ttf_reserved > (FT_Long)( size - len ) )
+ face->ttf_size > (FT_Long)( size - len ) )
{
FT_ERROR(( "t42_parse_sfnts:"
" invalid data in sfnts array\n" ));
@@ -771,31 +758,30 @@
}
/* Pad to a 4-byte boundary length */
- ttf_reserved += (FT_Long)( ( len + 3 ) & ~3U );
+ face->ttf_size += (FT_Long)( ( len + 3 ) & ~3U );
}
- ttf_reserved += 1;
status = OTHER_TABLES;
FT_TRACE2(( "\n" ));
- FT_TRACE2(( " allocating %ld bytes\n", ttf_reserved ));
+ FT_TRACE2(( " allocating %ld bytes\n", face->ttf_size + 1 ));
FT_TRACE2(( "\n" ));
- if ( FT_QREALLOC( face->ttf_data, ttf_reserved_prev,
- ttf_reserved ) )
+ if ( FT_QREALLOC( face->ttf_data, 12 + 16 * num_tables,
+ face->ttf_size + 1 ) )
goto Fail;
}
/* fall through */
case OTHER_TABLES:
/* all other tables are just copied */
- if ( ttf_count >= ttf_reserved )
+ if ( count >= face->ttf_size )
{
FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
- face->ttf_data[ttf_count++] = string_buf[n];
+ face->ttf_data[count++] = string_buf[n];
}
}
@@ -809,11 +795,6 @@
parser->root.error = error;
Exit:
- if ( parser->root.error )
- {
- FT_FREE( face->ttf_data );
- face->ttf_size = 0;
- }
if ( allocated )
FT_FREE( string_buf );
}