Commit dddd068e5dc398c290ca5b559c1ce5622b5d667f

David Turner 2007-03-05T18:23:25

fix a small memory leak when FT_Init_FreeType fails for some reason

diff --git a/ChangeLog b/ChangeLog
index ef73db4..017c412 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2007-03-05  David Turner  <david@freetype.org>
 
+	* src/base/ftinit.c (FT_Init_FreeType): fixed a small memory leak
+	when FT_Init_FreeType fails for some reason
+
 	* src/truetype/ttobs.c (tt_size_init_bytecode): bugfix, we need to
 	clear the x_ppem and y_ppem fields of the TT_Size.metrics structure,
 	note those of TT_Size.root.metrics. duh !!
diff --git a/src/base/ftinit.c b/src/base/ftinit.c
index ef32af5..ad6abea 100644
--- a/src/base/ftinit.c
+++ b/src/base/ftinit.c
@@ -124,7 +124,11 @@
     /* default drivers.                                        */
 
     error = FT_New_Library( memory, alibrary );
-    if ( !error )
+    if (error)
+    {
+      FT_Done_Memory(memory);
+    }
+    else
     {
       (*alibrary)->version_major = FREETYPE_MAJOR;
       (*alibrary)->version_minor = FREETYPE_MINOR;