Commit afe6016030f72685d2d618c78ecf9a45d831f487

Werner Lemberg 2008-12-01T12:53:00

GDEF tables need `glyph_count' too for validation. Problem reported by Chi Nguyen <chint@necsv.com>. * src/otvalid/otvgdef.c (otv_GDEF_validate), src/otvalid/otvalid.h (otv_GDEF_validate), src/otvalid/otvmod.c (otv_validate): Pass `glyph_count'.

diff --git a/ChangeLog b/ChangeLog
index 094cce8..43af8bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-12-01  Werner Lemberg  <wl@gnu.org>
+
+	GDEF tables need `glyph_count' too for validation.  Problem reported
+	by Chi Nguyen <chint@necsv.com>.
+
+	* src/otvalid/otvgdef.c (otv_GDEF_validate), src/otvalid/otvalid.h
+	(otv_GDEF_validate), src/otvalid/otvmod.c (otv_validate): Pass
+	`glyph_count'.
+
 2008-11-29  Werner Lemberg  <wl@gnu.org>
 
 	* src/autofit/afcjk.c, src/base/ftoutln.c, src/base/ftrfork.c,
diff --git a/src/otvalid/otvalid.h b/src/otvalid/otvalid.h
index 90255cd..eb99b9c 100644
--- a/src/otvalid/otvalid.h
+++ b/src/otvalid/otvalid.h
@@ -42,6 +42,7 @@ FT_BEGIN_HEADER
   otv_GDEF_validate( FT_Bytes      table,
                      FT_Bytes      gsub,
                      FT_Bytes      gpos,
+                     FT_UInt       glyph_count,
                      FT_Validator  valid );
 
   FT_LOCAL( void )
diff --git a/src/otvalid/otvgdef.c b/src/otvalid/otvgdef.c
index 77bd651..3633ad0 100644
--- a/src/otvalid/otvgdef.c
+++ b/src/otvalid/otvgdef.c
@@ -141,10 +141,13 @@
   /*************************************************************************/
   /*************************************************************************/
 
+  /* sets valid->glyph_count */
+
   FT_LOCAL_DEF( void )
   otv_GDEF_validate( FT_Bytes      table,
                      FT_Bytes      gsub,
                      FT_Bytes      gpos,
+                     FT_UInt       glyph_count,
                      FT_Validator  ftvalid )
   {
     OTV_ValidatorRec  validrec;
@@ -183,6 +186,8 @@
     else
       table_size = 10;              /* OpenType < 1.2  */
 
+    valid->glyph_count = glyph_count;
+
     OTV_OPTIONAL_OFFSET( GlyphClassDef );
     OTV_SIZE_CHECK( GlyphClassDef );
     if ( GlyphClassDef )
diff --git a/src/otvalid/otvmod.c b/src/otvalid/otvmod.c
index c280299..63c25f6 100644
--- a/src/otvalid/otvmod.c
+++ b/src/otvalid/otvmod.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType's OpenType validation module implementation (body).         */
 /*                                                                         */
-/*  Copyright 2004, 2005, 2006, 2007 by                                    */
+/*  Copyright 2004, 2005, 2006, 2007, 2008 by                              */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -168,7 +168,7 @@
     {
       ft_validator_init( &valid, gdef, gdef + len_gdef, FT_VALIDATE_DEFAULT );
       if ( ft_setjmp( valid.jump_buffer ) == 0 )
-        otv_GDEF_validate( gdef, gsub, gpos, &valid );
+        otv_GDEF_validate( gdef, gsub, gpos, face->num_glyphs, &valid );
       error = valid.error;
       if ( error )
         goto Exit;