* src/type1/t1afm.c (T1_Read_Metrics): Fix memory leak (#46229).
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
diff --git a/ChangeLog b/ChangeLog
index 19c2a8d..3ea8ecd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
-2015-10-18 Bungeman <bungeman@gmail.com>
+2015-10-20 Werner Lemberg <wl@gnu.org>
+
+ * src/type1/t1afm.c (T1_Read_Metrics): Fix memory leak (#46229).
+
+2015-10-19 Bungeman <bungeman@gmail.com>
[cid] Better handle invalid glyph stream offsets (#46221).
diff --git a/src/type1/t1afm.c b/src/type1/t1afm.c
index 7f32059..7a7bf82 100644
--- a/src/type1/t1afm.c
+++ b/src/type1/t1afm.c
@@ -239,9 +239,17 @@
AFM_ParserRec parser;
AFM_FontInfo fi = NULL;
FT_Error error = FT_ERR( Unknown_File_Format );
- T1_Font t1_font = &( (T1_Face)t1_face )->type1;
+ T1_Face face = (T1_Face)t1_face;
+ T1_Font t1_font = &face->type1;
+ if ( face->afm_data )
+ {
+ FT_TRACE1(( "T1_Read_Metrics:"
+ " Freeing previously attached metrics data.\n" ));
+ T1_Done_Metrics( memory, (AFM_FontInfo)face->afm_data );
+ }
+
if ( FT_NEW( fi ) ||
FT_FRAME_ENTER( stream->size ) )
goto Exit;
@@ -250,7 +258,7 @@
fi->Ascender = t1_font->font_bbox.yMax;
fi->Descender = t1_font->font_bbox.yMin;
- psaux = (PSAux_Service)( (T1_Face)t1_face )->psaux;
+ psaux = (PSAux_Service)face->psaux;
if ( psaux->afm_parser_funcs )
{
error = psaux->afm_parser_funcs->init( &parser,
@@ -298,7 +306,7 @@
if ( fi->NumKernPair )
{
t1_face->face_flags |= FT_FACE_FLAG_KERNING;
- ( (T1_Face)t1_face )->afm_data = fi;
+ face->afm_data = fi;
fi = NULL;
}
}