diff options
author | David Turner <david@freetype.org> | 2007-01-04 16:46:46 +0000 |
---|---|---|
committer | David Turner <david@freetype.org> | 2007-01-04 16:46:46 +0000 |
commit | a8cf42bb7a4f52f81969136fd4544ba8f58df12c (patch) | |
tree | 4180db8fe7d86ed231a5961332a6e13be13a5cf2 | |
parent | 6b87e6f0ff7867f3faf3959cbeaf6f8ac5122ab0 (diff) |
* src/pshinter/pshalgo.c: remove a stupid typo that results in no
hinting and a memory leak with some large Asian CFF fonts
* src/base/ftobjs.c (FT_Done_Library): remove a subtle memory leak
which happens when FT_Done_Library is called with opened CFF_Faces in
it. We need to close all faces before destroying the modules, or else
some bad things (memory leaks) may happen.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | src/base/ftobjs.c | 30 | ||||
-rw-r--r-- | src/pshinter/pshalgo.c | 2 |
3 files changed, 40 insertions, 2 deletions
@@ -1,3 +1,13 @@ +2007-01-04 David Turner <david@freetype.org> + + * src/pshinter/pshalgo.c: remove a stupid typo that results in no + hinting and a memory leak with some large Asian CFF fonts + + * src/base/ftobjs.c (FT_Done_Library): remove a subtle memory leak + which happens when FT_Done_Library is called with opened CFF_Faces in + it. We need to close all faces before destroying the modules, or else + some bad things (memory leaks) may happen. + 2007-01-02 Werner Lemberg <wl@gnu.org> * src/gxvalid/gxvkern.c (gxv_kern_subtable_fmt0_pairs_validate): diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 7909ea41..2384a27b 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -3758,7 +3758,35 @@ if ( library->generic.finalizer ) library->generic.finalizer( library ); - /* Close all modules in the library */ + /* Close all faces in the library. if we don't do + * this, we can have some subtle memory leaks. + * for example: + * + * - the cff font driver uses the pshinter module in cff_size_done + * - if the pshinter module is destroyed before the cff font driver, + * opened FT_Face objects managed by the driver will not be properly + * destroyed, resulting in a memory leak + */ + { + FT_UInt n; + + for ( n = 0; n < library->num_modules; n++ ) + { + FT_Module module = library->modules[n]; + FT_List faces; + + if ( (module->clazz->module_flags & FT_MODULE_FONT_DRIVER) == 0 ) + continue; + + faces = &FT_DRIVER(module)->faces_list; + while ( faces->head ) { + FT_Done_Face( FT_FACE(faces->head->data) ); + } + } + } + + + /* Close all other modules in the library */ #if 1 /* XXX Modules are removed in the reversed order so that */ /* type42 module is removed before truetype module. This */ diff --git a/src/pshinter/pshalgo.c b/src/pshinter/pshalgo.c index c3c972d8..83c07ddf 100644 --- a/src/pshinter/pshalgo.c +++ b/src/pshinter/pshalgo.c @@ -1866,7 +1866,7 @@ FT_Error error; - if ( !FT_NEW_ARRAY( strongs, num_strongs ) ) + if ( FT_NEW_ARRAY( strongs, num_strongs ) ) return; } |