Commit 4a15013a2988206cb126d6bc550e06f975439a13

Werner Lemberg 2015-11-25T07:53:49

* src/bdf/bdflib.c (bdf_load_font): Fix small memory leak (#46480). (_bdf_parse_glyphs): Always reset `p->glyph_name' after moving its contents.

diff --git a/ChangeLog b/ChangeLog
index bd5f2bb..42451d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-11-25  Werner Lemberg  <wl@gnu.org>
+
+	* src/bdf/bdflib.c (bdf_load_font): Fix small memory leak (#46480).
+
+	(_bdf_parse_glyphs): Always reset `p->glyph_name' after moving its
+	contents.
+
 2015-11-21  Werner Lemberg  <wl@gnu.org>
 
 	* include/freetype/internal/ftcalc.h: Don't use `register' keyword.
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index d1d1704..7b40f42 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -1790,6 +1790,9 @@
           glyph           = font->unencoded + font->unencoded_used;
           glyph->name     = p->glyph_name;
           glyph->encoding = (long)font->unencoded_used++;
+
+          /* Reset the initial glyph info. */
+          p->glyph_name = NULL;
         }
         else
         {
@@ -2589,6 +2592,7 @@
 
       memory = extmemory;
 
+      FT_FREE( p->glyph_name );
       FT_FREE( p );
     }
 
@@ -2600,7 +2604,6 @@
     memory = extmemory;
 
     FT_FREE( p->font );
-    FT_FREE( p->glyph_name );
 
     goto Exit;
   }