From 8d74a15d4ca06a5ddc1208e26cf48357d7b82376 Mon Sep 17 00:00:00 2001 From: handa Date: Thu, 26 Feb 2009 05:39:57 +0000 Subject: [PATCH] (free_stream): Check stream->buf before freeing it. (read_gdef_table): Do nothing if stream->buf is NULL. (read_header_part): If a font doesn't have a GDEF table, make a pseudo stream. --- src/otfopen.c | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/otfopen.c b/src/otfopen.c index 7e7cb34..fe9da87 100644 --- a/src/otfopen.c +++ b/src/otfopen.c @@ -164,7 +164,8 @@ make_stream_from_ft_face (FT_Face face, const char *name) static void free_stream (OTF_Stream *stream) { - free (stream->buf); + if (stream->buf) + free (stream->buf); free (stream); } @@ -1210,22 +1211,27 @@ read_gdef_table (OTF *otf, OTF_TableInfo *table, enum OTF_ReaderFlag flag) OTF_GDEF *gdef; OTF_CALLOC (gdef, 1, ""); - read_gdef_header (stream, (OTF_GDEFHeader *) &gdef->header); - if (gdef->header.GlyphClassDef) + if (stream->buf) { - gdef->glyph_class_def.offset = gdef->header.GlyphClassDef; - read_class_def_without_offset (otf, stream, &gdef->glyph_class_def); - } - if (gdef->header.AttachList) - read_attach_list (otf, stream, gdef->header.AttachList, - &gdef->attach_list); - if (gdef->header.LigCaretList) - read_lig_caret_list (otf, stream, gdef->header.LigCaretList, - &gdef->lig_caret_list); - if (gdef->header.MarkAttachClassDef) - { - gdef->mark_attach_class_def.offset = gdef->header.MarkAttachClassDef; - read_class_def_without_offset (otf, stream, &gdef->mark_attach_class_def); + read_gdef_header (stream, (OTF_GDEFHeader *) &gdef->header); + if (gdef->header.GlyphClassDef) + { + gdef->glyph_class_def.offset = gdef->header.GlyphClassDef; + read_class_def_without_offset (otf, stream, + &gdef->glyph_class_def); + } + if (gdef->header.AttachList) + read_attach_list (otf, stream, gdef->header.AttachList, + &gdef->attach_list); + if (gdef->header.LigCaretList) + read_lig_caret_list (otf, stream, gdef->header.LigCaretList, + &gdef->lig_caret_list); + if (gdef->header.MarkAttachClassDef) + { + gdef->mark_attach_class_def.offset = gdef->header.MarkAttachClassDef; + read_class_def_without_offset (otf, stream, + &gdef->mark_attach_class_def); + } } *table->address = gdef; @@ -2846,6 +2852,10 @@ read_header_part (OTF *otf, FILE *fp, FT_Face face) internal_data->table_info[OTF_TABLE_TYPE_GPOS].stream = stream; } + if (! internal_data->table_info[OTF_TABLE_TYPE_GDEF].stream) + /* We can simulate the GDEF table. */ + internal_data->table_info[OTF_TABLE_TYPE_GDEF].stream + = make_stream ("GDEF"); return 0; } -- 1.7.10.4