From bbf1dbf0b3d1816a776bb343fe3d7053ded7edaa Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Sun, 29 Aug 2021 03:23:39 +0000 Subject: freetype 2.11.0 git-svn-id: svn://tug.org/texlive/trunk@60354 c570f23f-e606-0410-a88d-b1316a301751 --- .../libs/freetype2/freetype-src/src/sfnt/sfwoff2.c | 57 +++++++++++++++------- 1 file changed, 40 insertions(+), 17 deletions(-) (limited to 'Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff2.c') diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff2.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff2.c index 5c8202f8237..df04072382e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff2.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfwoff2.c @@ -4,7 +4,7 @@ * * WOFF2 format management (base). * - * Copyright (C) 2019-2020 by + * Copyright (C) 2019-2021 by * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -101,7 +101,7 @@ } - FT_CALLBACK_DEF( int ) + FT_COMPARE_DEF( int ) compare_tags( const void* a, const void* b ) { @@ -341,6 +341,11 @@ #else /* !FT_CONFIG_OPTION_USE_BROTLI */ + FT_UNUSED( dst ); + FT_UNUSED( dst_size ); + FT_UNUSED( src ); + FT_UNUSED( src_size ); + FT_ERROR(( "woff2_decompress: Brotli support not available.\n" )); return FT_THROW( Unimplemented_Feature ); @@ -790,7 +795,7 @@ goto Fail; loca_buf_size = loca_values_size * offset_size; - if ( FT_NEW_ARRAY( loca_buf, loca_buf_size ) ) + if ( FT_QNEW_ARRAY( loca_buf, loca_buf_size ) ) goto Fail; dst = loca_buf; @@ -1852,11 +1857,10 @@ FT_NEW_ARRAY( indices, woff2.num_tables ) ) goto Exit; - FT_TRACE2(( - "\n" - " tag flags transform origLen transformLen offset\n" - " -----------------------------------------------------------\n" )); - /* " XXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX" */ + FT_TRACE2(( "\n" )); + FT_TRACE2(( " tag flags transform origLen transformLen offset\n" )); + FT_TRACE2(( " -----------------------------------------------------------\n" )); + /* " XXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX" */ for ( nn = 0; nn < woff2.num_tables; nn++ ) { @@ -2119,8 +2123,8 @@ /* Create a temporary array. */ - if ( FT_NEW_ARRAY( temp_indices, - ttc_font->num_tables ) ) + if ( FT_QNEW_ARRAY( temp_indices, + ttc_font->num_tables ) ) goto Exit; FT_TRACE4(( "Storing tables for TTC face index %d.\n", face_index )); @@ -2128,9 +2132,9 @@ temp_indices[nn] = indices[ttc_font->table_indices[nn]]; /* Resize array to required size. */ - if ( FT_RENEW_ARRAY( indices, - woff2.num_tables, - ttc_font->num_tables ) ) + if ( FT_QRENEW_ARRAY( indices, + woff2.num_tables, + ttc_font->num_tables ) ) goto Exit; for ( nn = 0; nn < ttc_font->num_tables; nn++ ) @@ -2170,8 +2174,8 @@ } /* Write sfnt header. */ - if ( FT_ALLOC( sfnt, sfnt_size ) || - FT_NEW( sfnt_stream ) ) + if ( FT_QALLOC( sfnt, sfnt_size ) || + FT_NEW( sfnt_stream ) ) goto Exit; sfnt_header = sfnt; @@ -2209,6 +2213,25 @@ sizeof ( WOFF2_Table ), compare_tags ); + /* reject fonts that have multiple tables with the same tag */ + for ( nn = 1; nn < woff2.num_tables; nn++ ) + { + FT_ULong tag = indices[nn]->Tag; + + + if ( tag == indices[nn - 1]->Tag ) + { + FT_ERROR(( "woff2_open_font:" + " multiple tables with tag `%c%c%c%c'.\n", + (FT_Char)( tag >> 24 ), + (FT_Char)( tag >> 16 ), + (FT_Char)( tag >> 8 ), + (FT_Char)( tag ) )); + error = FT_THROW( Invalid_Table ); + goto Exit; + } + } + if ( woff2.uncompressed_size < 1 ) { error = FT_THROW( Invalid_Table ); @@ -2223,8 +2246,8 @@ } /* Allocate memory for uncompressed table data. */ - if ( FT_ALLOC( uncompressed_buf, woff2.uncompressed_size ) || - FT_FRAME_ENTER( woff2.totalCompressedSize ) ) + if ( FT_QALLOC( uncompressed_buf, woff2.uncompressed_size ) || + FT_FRAME_ENTER( woff2.totalCompressedSize ) ) goto Exit; /* Uncompress the stream. */ -- cgit v1.2.3