shithub: freetype+ttf2subf

Download patch

ref: f4c94d4b5f6b3e13415025ffa6fa07415d00104d
parent: 5d86cdce7e2f0885016d0299cef9fe2359025cf0
author: Werner Lemberg <[email protected]>
date: Sat Jun 19 12:08:31 EDT 2010

Fix Savannah bug #30135.

* src/bdf/bdflib.c (_bdf_list_join): Don't modify value in static
string `empty'.
(_bdf_parse_glyph): Avoid memory leak in case of error.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-06-19  Werner Lemberg  <[email protected]>
+
+	Fix Savannah bug #30135.
+
+	* src/bdf/bdflib.c (_bdf_list_join): Don't modify value in static
+	string `empty'.
+	(_bdf_parse_glyph): Avoid memory leak in case of error.
+
 2010-06-15  Werner Lemberg  <[email protected]>
 
 	Fix Savannah bug #30108.
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -1,6 +1,6 @@
 /*
  * Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
+ * Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
  *   Francesco Zappa Nardelli
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -470,6 +470,11 @@
   }
 
 
+  /* An empty string for empty fields. */
+
+  static const char  empty[1] = { 0 };      /* XXX eliminate this */
+
+
   static char *
   _bdf_list_join( _bdf_list_t*    list,
                   int             c,
@@ -494,7 +499,8 @@
       if ( i + 1 < list->used )
         dp[j++] = (char)c;
     }
-    dp[j] = 0;
+    if ( dp != empty )
+      dp[j] = 0;
 
     *alen = j;
     return dp;
@@ -501,11 +507,6 @@
   }
 
 
-  /* An empty string for empty fields. */
-
-  static const char  empty[1] = { 0 };      /* XXX eliminate this */
-
-
   static FT_Error
   _bdf_list_split( _bdf_list_t*   list,
                    char*          separators,
@@ -1868,6 +1869,9 @@
     error = BDF_Err_Invalid_File_Format;
 
   Exit:
+    if ( error && ( p->flags & _BDF_GLYPH ) )
+      FT_FREE( p->glyph_name );
+
     return error;
   }