Fix memory leak described in Savannah bug #16768 * src/type1/t1afm.c (T1_Read_Metrics): fix memory leak which happened when the metrics file doesn't have kerning pairs.
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
diff --git a/ChangeLog b/ChangeLog
index d22ba17..166eb78 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-06-07 David Turner <david@freetype.org>
+
+ Fix memory leak described in Savannah bug #16768
+
+ * src/type1/t1afm.c (T1_Read_Metrics): fix memory leak
+ which happened when the metrics file doesn't have kerning
+ pairs.
+
2006-06-06 David Turner <david@freetype.org>
Fix memory leak described in Savannah bug #16759.
diff --git a/src/type1/t1afm.c b/src/type1/t1afm.c
index 379b330..f4d00d6 100644
--- a/src/type1/t1afm.c
+++ b/src/type1/t1afm.c
@@ -73,7 +73,7 @@
#undef KERN_INDEX
-#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 )
+#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)(g1) << 16 ) | (g2) )
/* compare two kerning pairs */
@@ -233,14 +233,9 @@
T1_Font t1_font = &( (T1_Face)t1_face )->type1;
- if ( FT_NEW( fi ) )
- return error;
-
- if ( FT_FRAME_ENTER( stream->size ) )
- {
- FT_FREE( fi );
- return error;
- }
+ if ( FT_NEW( fi ) ||
+ FT_FRAME_ENTER( stream->size ) )
+ goto Exit;
fi->FontBBox = t1_font->font_bbox;
fi->Ascender = t1_font->font_bbox.yMax;
@@ -292,11 +287,16 @@
{
t1_face->face_flags |= FT_FACE_FLAG_KERNING;
( (T1_Face)t1_face )->afm_data = fi;
+ fi = NULL;
}
}
FT_FRAME_EXIT();
+ Exit:
+ if ( fi != NULL )
+ T1_Done_Metrics( memory, fi );
+
return error;
}