shithub: freetype+ttf2subf

Download patch

ref: 5f1f75076cfda129d6cbf86a634fcadfdfc0c9f6
parent: f1a23cbf0f11a4c81a427efd77d0615edc4d08ff
author: David Turner <[email protected]>
date: Wed Jun 7 01:11:50 EDT 2006

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.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-06-07  David Turner  <[email protected]>
+
+  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  <[email protected]>
 
 	Fix memory leak described in Savannah bug #16759.
--- 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,15 +233,10 @@
     T1_Font        t1_font = &( (T1_Face)t1_face )->type1;
 
 
-    if ( FT_NEW( fi ) )
-      return error;
+    if ( FT_NEW( fi )                   ||
+         FT_FRAME_ENTER( stream->size ) )
+      goto Exit;
 
-    if ( FT_FRAME_ENTER( stream->size ) )
-    {
-      FT_FREE( fi );
-      return error;
-    }
-
     fi->FontBBox  = t1_font->font_bbox;
     fi->Ascender  = t1_font->font_bbox.yMax;
     fi->Descender = t1_font->font_bbox.yMin;
@@ -292,10 +287,15 @@
       {
         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;
   }