From 2eaf0cf8fd6e7c290497fedb08134a89e7b49b1d Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 19 Mar 2015 17:34:42 +0400 Subject: Update bundled FreeType to 2.5.5 Removed everything, imported with help of import_from_tarball.sh script, and then added a pre-generated builds/unix/ftconfig.h Task-number: QTBUG-44648 Change-Id: Iea948e41f7761f1580382b3763d04c7a61383382 Reviewed-by: Lars Knoll --- src/3rdparty/freetype/src/pfr/pfrgload.c | 50 +++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 17 deletions(-) (limited to 'src/3rdparty/freetype/src/pfr/pfrgload.c') diff --git a/src/3rdparty/freetype/src/pfr/pfrgload.c b/src/3rdparty/freetype/src/pfr/pfrgload.c index 6fe6e4225a..2ce093779c 100644 --- a/src/3rdparty/freetype/src/pfr/pfrgload.c +++ b/src/3rdparty/freetype/src/pfr/pfrgload.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR glyph loader (body). */ /* */ -/* Copyright 2002, 2003, 2005, 2007 by */ +/* Copyright 2002, 2003, 2005, 2007, 2010, 2013 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -135,7 +135,7 @@ /* check that we have begun a new path */ if ( !glyph->path_begun ) { - error = PFR_Err_Invalid_Table; + error = FT_THROW( Invalid_Table ); FT_ERROR(( "pfr_glyph_line_to: invalid glyph data\n" )); goto Exit; } @@ -171,7 +171,7 @@ /* check that we have begun a new path */ if ( !glyph->path_begun ) { - error = PFR_Err_Invalid_Table; + error = FT_THROW( Invalid_Table ); FT_ERROR(( "pfr_glyph_line_to: invalid glyph data\n" )); goto Exit; } @@ -248,7 +248,7 @@ FT_Byte* p, FT_Byte* limit ) { - FT_Error error = 0; + FT_Error error = FT_Err_Ok; FT_Memory memory = glyph->loader->memory; FT_UInt flags, x_count, y_count, i, count, mask; FT_Int x; @@ -268,8 +268,8 @@ { PFR_CHECK( 1 ); count = PFR_NEXT_BYTE( p ); - x_count = ( count & 15 ); - y_count = ( count >> 4 ); + x_count = count & 15; + y_count = count >> 4; } else { @@ -388,7 +388,7 @@ case 2: /* horizontal line to */ FT_TRACE6(( "- horizontal line to cx.%d", format_low )); - if ( format_low > x_count ) + if ( format_low >= x_count ) goto Failure; pos[0].x = glyph->x_control[format_low]; pos[0].y = pos[3].y; @@ -398,7 +398,7 @@ case 3: /* vertical line to */ FT_TRACE6(( "- vertical line to cy.%d", format_low )); - if ( format_low > y_count ) + if ( format_low >= y_count ) goto Failure; pos[0].x = pos[3].x; pos[0].y = glyph->y_control[format_low]; @@ -440,7 +440,7 @@ case 0: /* 8-bit index */ PFR_CHECK( 1 ); idx = PFR_NEXT_BYTE( p ); - if ( idx > x_count ) + if ( idx >= x_count ) goto Failure; cur->x = glyph->x_control[idx]; FT_TRACE7(( " cx#%d", idx )); @@ -470,7 +470,7 @@ case 0: /* 8-bit index */ PFR_CHECK( 1 ); idx = PFR_NEXT_BYTE( p ); - if ( idx > y_count ) + if ( idx >= y_count ) goto Failure; cur->y = glyph->y_control[idx]; FT_TRACE7(( " cy#%d", idx )); @@ -546,7 +546,7 @@ Failure: Too_Short: - error = PFR_Err_Invalid_Table; + error = FT_THROW( Invalid_Table ); FT_ERROR(( "pfr_glyph_load_simple: invalid glyph data\n" )); goto Exit; } @@ -558,7 +558,7 @@ FT_Byte* p, FT_Byte* limit ) { - FT_Error error = 0; + FT_Error error = FT_Err_Ok; FT_GlyphLoader loader = glyph->loader; FT_Memory memory = loader->memory; PFR_SubGlyph subglyph; @@ -598,6 +598,16 @@ FT_UInt new_max = ( org_count + count + 3 ) & (FT_UInt)-4; + /* we arbitrarily limit the number of subglyphs */ + /* to avoid endless recursion */ + if ( new_max > 64 ) + { + error = FT_THROW( Invalid_Table ); + FT_ERROR(( "pfr_glyph_load_compound:" + " too many compound glyphs components\n" )); + goto Exit; + } + if ( FT_RENEW_ARRAY( glyph->subs, glyph->max_subs, new_max ) ) goto Exit; @@ -699,7 +709,7 @@ Failure: Too_Short: - error = PFR_Err_Invalid_Table; + error = FT_THROW( Invalid_Table ); FT_ERROR(( "pfr_glyph_load_compound: invalid glyph data\n" )); goto Exit; } @@ -743,6 +753,9 @@ count = glyph->num_subs - old_count; + FT_TRACE4(( "compound glyph with %d elements (offset %lu):\n", + count, offset )); + /* now, load each individual glyph */ for ( n = 0; n < count; n++ ) { @@ -750,6 +763,8 @@ PFR_SubGlyph subglyph; + FT_TRACE4(( " subglyph %d:\n", n )); + subglyph = glyph->subs + old_count + n; old_points = base->n_points; @@ -757,7 +772,7 @@ subglyph->gps_offset, subglyph->gps_size ); if ( error ) - goto Exit; + break; /* note that `glyph->subs' might have been re-allocated */ subglyph = glyph->subs + old_count + n; @@ -791,9 +806,13 @@ /* proceed to next sub-glyph */ } + + FT_TRACE4(( "end compound glyph with %d elements\n", count )); } else { + FT_TRACE4(( "simple glyph (offset %lu)\n", offset )); + /* load a simple glyph */ error = pfr_glyph_load_simple( glyph, p, limit ); @@ -805,9 +824,6 @@ } - - - FT_LOCAL_DEF( FT_Error ) pfr_glyph_load( PFR_Glyph glyph, FT_Stream stream, -- cgit v1.2.3