ftpatent: Fix a bug by wrong usage of service->table_info().
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
diff --git a/ChangeLog b/ChangeLog
index ffa116e..1592136 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2009-06-28 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
+ 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 <wl@gnu.org>
[psaux, cff] Protect against nested `seac' calls.
diff --git a/include/freetype/internal/services/svsfnt.h b/include/freetype/internal/services/svsfnt.h
index f4ae93c..30bb162 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 6e78eca..5bb4e4e 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 9f129d8..2153868 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 beada47..5429fde 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;