Commit 4086fb7caf41e33137e548e43a49a97b127cd369

Werner Lemberg 2012-03-01T08:55:40

[bdf] Fix Savannah bug #35641. * src/bdf/bdflib.c (_bdf_parse_glyphs) <DWIDTH, BBX>: Abort if _BDF_ENCODING isn't set. We need this because access to the `glyph' variable might be undefined otherwise.

diff --git a/ChangeLog b/ChangeLog
index 75deee3..41830b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2012-02-29  Werner Lemberg  <wl@gnu.org>
 
+	[bdf] Fix Savannah bug #35641.
+
+	* src/bdf/bdflib.c (_bdf_parse_glyphs) <DWIDTH, BBX>: Abort if
+	_BDF_ENCODING isn't set.  We need this because access to the `glyph'
+	variable might be undefined otherwise.
+
+2012-02-29  Werner Lemberg  <wl@gnu.org>
+
 	[truetype] Fix Savannah bug #35640.
 
 	* src/truetype/ttinterp.c (SkipCode, TT_RunIns): Fix boundary check
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index 8a5ffce..5a718cb 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -1779,12 +1779,7 @@
     if ( ft_memcmp( line, "SWIDTH", 6 ) == 0 )
     {
       if ( !( p->flags & _BDF_ENCODING ) )
-      {
-        /* Missing ENCODING field. */
-        FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "ENCODING" ));
-        error = BDF_Err_Missing_Encoding_Field;
-        goto Exit;
-      }
+        goto Missing_Encoding;
 
       error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
       if ( error )
@@ -1799,6 +1794,9 @@
     /* Expect the DWIDTH (scalable width) field next. */
     if ( ft_memcmp( line, "DWIDTH", 6 ) == 0 )
     {
+      if ( !( p->flags & _BDF_ENCODING ) )
+        goto Missing_Encoding;
+
       error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
       if ( error )
         goto Exit;
@@ -1824,6 +1822,9 @@
     /* Expect the BBX field next. */
     if ( ft_memcmp( line, "BBX", 3 ) == 0 )
     {
+      if ( !( p->flags & _BDF_ENCODING ) )
+        goto Missing_Encoding;
+
       error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
       if ( error )
         goto Exit;
@@ -1924,6 +1925,12 @@
 
     FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG9, lineno ));
     error = BDF_Err_Invalid_File_Format;
+    goto Exit;
+
+  Missing_Encoding:
+    /* Missing ENCODING field. */
+    FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "ENCODING" ));
+    error = BDF_Err_Missing_Encoding_Field;
 
   Exit:
     if ( error && ( p->flags & _BDF_GLYPH ) )