* src/base/ftobjs.c (FT_Done_Library): Modules are removed in the reversed order so that type42 module is removed before truetype module. This avoids double free in some occasions.
diff --git a/ChangeLog b/ChangeLog
index 6ac2eff..b5b84b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-02-28 Chia-I Wu <b90201047@ntu.edu.tw>
+
+ * src/base/ftobjs.c (FT_Done_Library): Modules are removed in the
+ reversed order so that type42 module is removed before truetype
+ module. This avoids double free in some occasions.
+
2006-02-28 David Turner <david@freetype.org>
* tagging VER-2-2-0-RC4
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 16aac1a..0ae061a 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -3721,8 +3721,12 @@
/* Close all modules in the library */
#if 1
+ /* XXX Modules are removed in the reversed order so that */
+ /* type42 module is removed before truetype module. This */
+ /* avoids double free in some occasions. It is a hack. */
while ( library->num_modules > 0 )
- FT_Remove_Module( library, library->modules[0] );
+ FT_Remove_Module( library,
+ library->modules[library->num_modules - 1] );
#else
{
FT_UInt n;