Commit b185747dd6128526e4794a0768ac42b1570cc302

Werner Lemberg 2015-10-17T14:21:41

[bdf] Prevent memory leak (#46217). * src/bdf/bdflib.c (_bdf_parse_glyphs) <STARTCHAR>: Check _BDF_GLYPH_BITS.

diff --git a/ChangeLog b/ChangeLog
index 2374771..7525c10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2015-10-17  Werner Lemberg  <wl@gnu.org>
 
+	[bdf] Prevent memory leak (#46217).
+
+	* src/bdf/bdflib.c (_bdf_parse_glyphs) <STARTCHAR>: Check
+	_BDF_GLYPH_BITS.
+
+2015-10-17  Werner Lemberg  <wl@gnu.org>
+
 	[bdf] Use stream size to adjust number of glyphs.
 
 	* src/bdf/bdflib.c (ACMSG17): New message macro.
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index 9568f1b..c1619e6 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -1650,6 +1650,14 @@
     /* Check for the STARTCHAR field. */
     if ( _bdf_strncmp( line, "STARTCHAR", 9 ) == 0 )
     {
+      if ( p->flags & _BDF_GLYPH_BITS )
+      {
+        /* Missing ENDCHAR field. */
+        FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "ENDCHAR" ));
+        error = FT_THROW( Missing_Startchar_Field );
+        goto Exit;
+      }
+
       /* Set the character name in the parse info first until the */
       /* encoding can be checked for an unencoded character.      */
       FT_FREE( p->glyph_name );