Fix Savannah bug #30220. * include/freetype/fterrdef.h (BDF_Err_Missing_Fontboundingbox_Field): New error code. * src/bdf/bdflib.c (_bdf_parse_start): Check for missing `FONTBOUNDINGBOX' field. Avoid memory leak if there are multiple `FONT' lines (which is invalid but doesn't hurt).
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
diff --git a/ChangeLog b/ChangeLog
index a1f4288..f3fd6ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2010-06-23 Werner Lemberg <wl@gnu.org>
+
+ Fix Savannah bug #30220.
+
+ * include/freetype/fterrdef.h
+ (BDF_Err_Missing_Fontboundingbox_Field): New error code.
+
+ * src/bdf/bdflib.c (_bdf_parse_start): Check for missing
+ `FONTBOUNDINGBOX' field.
+ Avoid memory leak if there are multiple `FONT' lines (which is
+ invalid but doesn't hurt).
+
2010-06-21 Werner Lemberg <wl@gnu.org>
Fix Savannah bug #30168.
diff --git a/include/freetype/fterrdef.h b/include/freetype/fterrdef.h
index d7ad256..ceda1a9 100644
--- a/include/freetype/fterrdef.h
+++ b/include/freetype/fterrdef.h
@@ -4,7 +4,7 @@
/* */
/* FreeType error codes (specification). */
/* */
-/* Copyright 2002, 2004, 2006, 2007 by */
+/* Copyright 2002, 2004, 2006, 2007, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -220,19 +220,21 @@
"`FONT' field missing" )
FT_ERRORDEF_( Missing_Size_Field, 0xB2, \
"`SIZE' field missing" )
- FT_ERRORDEF_( Missing_Chars_Field, 0xB3, \
+ FT_ERRORDEF_( Missing_Fontboundingbox_Field, 0xB3, \
+ "`FONTBOUNDINGBOX' field missing" )
+ FT_ERRORDEF_( Missing_Chars_Field, 0xB4, \
"`CHARS' field missing" )
- FT_ERRORDEF_( Missing_Startchar_Field, 0xB4, \
+ FT_ERRORDEF_( Missing_Startchar_Field, 0xB5, \
"`STARTCHAR' field missing" )
- FT_ERRORDEF_( Missing_Encoding_Field, 0xB5, \
+ FT_ERRORDEF_( Missing_Encoding_Field, 0xB6, \
"`ENCODING' field missing" )
- FT_ERRORDEF_( Missing_Bbx_Field, 0xB6, \
+ FT_ERRORDEF_( Missing_Bbx_Field, 0xB7, \
"`BBX' field missing" )
- FT_ERRORDEF_( Bbx_Too_Big, 0xB7, \
+ FT_ERRORDEF_( Bbx_Too_Big, 0xB8, \
"`BBX' too big" )
- FT_ERRORDEF_( Corrupted_Font_Header, 0xB8, \
+ FT_ERRORDEF_( Corrupted_Font_Header, 0xB9, \
"Font header corrupted or missing fields" )
- FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xB9, \
+ FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xBA, \
"Font glyphs corrupted or missing fields" )
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index 6ce5c26..e4553e0 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -2082,6 +2082,14 @@
/* Check for the start of the properties. */
if ( ft_memcmp( line, "STARTPROPERTIES", 15 ) == 0 )
{
+ if ( !(p->flags & _BDF_FONT_BBX ) )
+ {
+ /* Missing the FONTBOUNDINGBOX field. */
+ FT_ERROR(( "_bdf_parse_start: " ERRMSG1, lineno, "FONTBOUNDINGBOX" ));
+ error = BDF_Err_Missing_Fontboundingbox_Field;
+ goto Exit;
+ }
+
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
@@ -2144,6 +2152,9 @@
goto Exit;
}
+ /* Allowing multiple `FONT' lines (which is invalid) doesn't hurt... */
+ FT_FREE( p->font->name );
+
if ( FT_NEW_ARRAY( p->font->name, slen + 1 ) )
goto Exit;
FT_MEM_COPY( p->font->name, s, slen + 1 );