From ad289d139f90bd9f439fdcde151127a2912f8834 Mon Sep 17 00:00:00 2001 From: suzuki toshiya Date: Mon, 29 Jun 2009 03:09:17 +0900 Subject: [PATCH] ftpatent: Fix a bug by wrong usage of service->table_info(). --- ChangeLog | 15 +++++++++++++++ include/freetype/internal/services/svsfnt.h | 1 + src/base/ftobjs.c | 3 ++- src/base/ftpatent.c | 13 ++++++++----- src/sfnt/sfdriver.c | 4 +++- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index ffa116ea9..15921365d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2009-06-28 suzuki toshiya + + ftpatent: Fix a bug by wrong usage of service->table_info(). + http://lists.gnu.org/archive/html/freetype-devel/2008-12/msg00039.html + + * include/freetype/internal/services/svsfnt.h: Extend + FT_SFNT_TableInfoFunc() to take new argument to obtain the offset + to the specified table. + * src/sfnt/sfdriver.c (sfnt_table_info): Extend to return the + table-offset to the caller function. + * src/base/ftpatent.c (_tt_check_patents_in_table): Use new + service->table_info(). + * src/base/ftobjs.c (FT_Sfnt_Table_Info): Synchronize to new + service->table_info(). + 2009-06-28 Werner Lemberg [psaux, cff] Protect against nested `seac' calls. diff --git a/include/freetype/internal/services/svsfnt.h b/include/freetype/internal/services/svsfnt.h index f4ae93c52..30bb1620f 100644 --- a/include/freetype/internal/services/svsfnt.h +++ b/include/freetype/internal/services/svsfnt.h @@ -58,6 +58,7 @@ FT_BEGIN_HEADER (*FT_SFNT_TableInfoFunc)( FT_Face face, FT_UInt idx, FT_ULong *tag, + FT_ULong *offset, FT_ULong *length ); diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 6e78eca69..5bb4e4ec8 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -3397,6 +3397,7 @@ FT_ULong *length ) { FT_Service_SFNT_Table service; + FT_ULong offset; if ( !face || !FT_IS_SFNT( face ) ) @@ -3406,7 +3407,7 @@ if ( service == NULL ) return FT_Err_Unimplemented_Feature; - return service->table_info( face, table_index, tag, length ); + return service->table_info( face, table_index, tag, &offset, length ); } diff --git a/src/base/ftpatent.c b/src/base/ftpatent.c index 9f129d8f0..2153868cb 100644 --- a/src/base/ftpatent.c +++ b/src/base/ftpatent.c @@ -113,7 +113,7 @@ FT_ULong tag ) { FT_Stream stream = face->stream; - FT_Error error; + FT_Error error = FT_Err_Ok; FT_Service_SFNT_Table service; FT_Bool result = FALSE; @@ -122,15 +122,18 @@ if ( service ) { - FT_ULong offset, size; + FT_UInt i = 0; + FT_ULong tag_i = 0, offset_i, length_i; + for ( i = 0; !error && tag_i != tag ; i++ ) + error = service->table_info( face, i, + &tag_i, &offset_i, &length_i ); - error = service->table_info( face, tag, &offset, &size ); if ( error || - FT_STREAM_SEEK( offset ) ) + FT_STREAM_SEEK( offset_i ) ) goto Exit; - result = _tt_check_patents_in_range( stream, size ); + result = _tt_check_patents_in_range( stream, length_i ); } Exit: diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c index beada479f..5429fde41 100644 --- a/src/sfnt/sfdriver.c +++ b/src/sfnt/sfdriver.c @@ -104,15 +104,17 @@ sfnt_table_info( TT_Face face, FT_UInt idx, FT_ULong *tag, + FT_ULong *offset, FT_ULong *length ) { - if ( !tag || !length ) + if ( !tag || !offset || !length ) return SFNT_Err_Invalid_Argument; if ( idx >= face->num_tables ) return SFNT_Err_Table_Missing; *tag = face->dir_tables[idx].Tag; + *offset = face->dir_tables[idx].Offset; *length = face->dir_tables[idx].Length; return SFNT_Err_Ok;