* src/bdf/bdflib.c (_bdf_readstream): Allocate `buf' dynamically. (_bdf_parse_glyphs): Use correct size for allocating `font->unencoded'. (bdf_load_font): Free array conditionally. Return proper error code in case of failure. * src/bdf/bdfdrivr.c (BDF_Face_Init): Make it more robust against unusual fonts.
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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
diff --git a/ChangeLog b/ChangeLog
index a8d635c..8b07ea3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2002-05-29 Detlef W�rkner <TetiSoft@apg.lahn.de>
+
+ * src/bdf/bdflib.c (_bdf_readstream): Allocate `buf' dynamically.
+ (_bdf_parse_glyphs): Use correct size for allocating
+ `font->unencoded'.
+ (bdf_load_font): Free array conditionally.
+ Return proper error code in case of failure.
+ * src/bdf/bdfdrivr.c (BDF_Face_Init): Make it more robust against
+ unusual fonts.
+
2002-05-29 Werner Lemberg <wl@gnu.org>
* src/bdf/descrip.mms, src/type42/descrip.mms: New files.
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index ae3ba5b..8e5dd62 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -128,9 +128,10 @@ THE SOFTWARE.
prop = bdf_get_font_property( font, (char *)"SPACING" );
if ( prop != NULL )
if ( prop->format == BDF_ATOM )
- if ( ( *(prop->value.atom) == 'M' ) ||
- ( *(prop->value.atom) == 'C' ) )
- root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
+ if ( prop->value.atom != NULL )
+ if ( ( *(prop->value.atom) == 'M' ) ||
+ ( *(prop->value.atom) == 'C' ) )
+ root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
/* FZ XXX: TO DO: FT_FACE_FLAGS_VERTICAL */
/* FZ XXX: I need a font to implement this */
@@ -139,18 +140,20 @@ THE SOFTWARE.
prop = bdf_get_font_property( font, (char *)"SLANT" );
if ( prop != NULL )
if ( prop->format == BDF_ATOM )
- if ( ( *(prop->value.atom) == 'O' ) ||
- ( *(prop->value.atom) == 'I' ) )
- root->style_flags |= FT_STYLE_FLAG_ITALIC;
+ if ( prop->value.atom != NULL )
+ if ( ( *(prop->value.atom) == 'O' ) ||
+ ( *(prop->value.atom) == 'I' ) )
+ root->style_flags |= FT_STYLE_FLAG_ITALIC;
prop = bdf_get_font_property( font, (char *)"WEIGHT_NAME" );
if ( prop != NULL )
if ( prop->format == BDF_ATOM )
- if ( *(prop->value.atom) == 'B' )
- root->style_flags |= FT_STYLE_FLAG_BOLD;
+ if ( prop->value.atom != NULL )
+ if ( *(prop->value.atom) == 'B' )
+ root->style_flags |= FT_STYLE_FLAG_BOLD;
prop = bdf_get_font_property( font, (char *)"FAMILY_NAME" );
- if ( prop != NULL )
+ if ( ( prop != NULL ) && ( prop->value.atom != NULL ) )
{
int l = ft_strlen( prop->value.atom ) + 1;
@@ -237,7 +240,9 @@ THE SOFTWARE.
if ( ( charset_registry != NULL ) && ( charset_encoding != NULL ) )
{
if ( ( charset_registry->format == BDF_ATOM ) &&
- ( charset_encoding->format == BDF_ATOM ) )
+ ( charset_encoding->format == BDF_ATOM ) &&
+ ( charset_registry->value.atom != NULL ) &&
+ ( charset_encoding->value.atom != NULL ) )
{
if ( FT_NEW_ARRAY( face->charset_encoding,
strlen( charset_encoding->value.atom ) + 1 ) )
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index b3c503f..dde4e85 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -643,8 +643,8 @@
unsigned long lineno;
int n, res, done, refill, bytes, hold;
char *ls, *le, *pp, *pe, *hp;
- /* XXX: Use a dynamic buffer */
- char buf[65536L];
+ char *buf = 0;
+ FT_Memory memory = stream->memory;
FT_Error error = BDF_Err_Ok;
@@ -654,6 +654,9 @@
goto Exit;
}
+ if ( FT_NEW_ARRAY( buf, 65536L ) )
+ goto Exit;
+
cb = callback;
lineno = 1;
buf[0] = 0;
@@ -732,6 +735,7 @@
*lno = lineno;
Exit:
+ FT_FREE( buf );
return error;
}
@@ -1619,7 +1623,7 @@
{
if ( font->unencoded_size == 0 )
{
- if ( FT_NEW_ARRAY( font->unencoded, 2 ) )
+ if ( FT_NEW_ARRAY( font->unencoded, 4 ) )
goto Exit;
}
else
@@ -2290,7 +2294,8 @@
}
/* Free up the list used during the parsing. */
- FT_FREE( p.list.field );
+ if ( memory != NULL )
+ FT_FREE( p.list.field );
if ( p.font != 0 )
{
@@ -2306,6 +2311,8 @@
p.font->comments[p.font->comments_len] = 0;
}
}
+ else if ( error == BDF_Err_Ok )
+ error = BDF_Err_Invalid_File_Format;
*font = p.font;