diff options
Diffstat (limited to 'src/base/ftobjs.c')
-rw-r--r-- | src/base/ftobjs.c | 30 |
1 files changed, 29 insertions, 1 deletions
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 */ |