Commit c9ca6ffc9442b4b127f948e2d993454aa7791e59

Werner Lemberg 2014-12-11T13:39:39

* src/base/ftobjs.c (FT_Get_Glyph_Name): Fix off-by-one check. Problem reported by Dennis Felsing <dennis@felsin9.de>.

diff --git a/ChangeLog b/ChangeLog
index 12fab2b..bbc0422 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2014-12-11  Werner Lemberg  <wl@gnu.org>
 
+	* src/base/ftobjs.c (FT_Get_Glyph_Name): Fix off-by-one check.
+
+	Problem reported by Dennis Felsing <dennis@felsin9.de>.
+
+2014-12-11  Werner Lemberg  <wl@gnu.org>
+
 	* src/type42/t42parse.c (t42_parse_sfnts): Check `string_size'.
 
 	Problem reported by Dennis Felsing <dennis@felsin9.de>.
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index c6e4b19..ee15a01 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -3648,8 +3648,10 @@
     /* clean up buffer */
     ((FT_Byte*)buffer)[0] = '\0';
 
-    if ( (FT_Long)glyph_index > face->num_glyphs ||
-         !FT_HAS_GLYPH_NAMES( face )             )
+    if ( (FT_Long)glyph_index >= face->num_glyphs )
+      return FT_THROW( Invalid_Glyph_Index );
+
+    if ( !FT_HAS_GLYPH_NAMES( face ) )
       return FT_THROW( Invalid_Argument );
 
     FT_FACE_LOOKUP_SERVICE( face, service, GLYPH_DICT );