CVSROOT: /cvsroot/freetype Module name: freetype2 Changes by: David Turner <freetype> 06/06/06 08:14:14
Modified files: . : ChangeLog include/freetype/internal/services: svpscmap.h src/cff : cffcmap.c src/psaux : t1cmap.c src/psnames : psmodule.c Log message: * include/freetype/internal/services/svpscmap.h, src/cff/cffcmap.c, src/psaux/t1cmap.c, src/psnames/psmodule.c: Fix for the memory leak described in bug #16759. We change 'ps_unicodes_init' so that it also takes a 'free_glyph_name' callback to release the glyph names returned by 'get_glyph_name' CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/freetype2/ChangeLog?cvsroot=freetype&r1=1.1344&r2=1.1345 http://cvs.savannah.gnu.org/viewcvs/freetype2/include/freetype/internal/services/svpscmap.h?cvsroot=freetype&r1=1.4&r2=1.5 http://cvs.savannah.gnu.org/viewcvs/freetype2/src/cff/cffcmap.c?cvsroot=freetype&r1=1.15&r2=1.16 http://cvs.savannah.gnu.org/viewcvs/freetype2/src/psaux/t1cmap.c?cvsroot=freetype&r1=1.17&r2=1.18 http://cvs.savannah.gnu.org/viewcvs/freetype2/src/psnames/psmodule.c?cvsroot=freetype&r1=1.43&r2=1.44 Patches: Index: ChangeLog =================================================================== RCS file: /cvsroot/freetype/freetype2/ChangeLog,v retrieving revision 1.1344 retrieving revision 1.1345 diff -u -b -r1.1344 -r1.1345 --- ChangeLog 4 Jun 2006 15:17:40 -0000 1.1344 +++ ChangeLog 6 Jun 2006 08:14:14 -0000 1.1345 @@ -1,3 +1,13 @@ +2006-06-06 David Turner <[EMAIL PROTECTED]> + + * include/freetype/internal/services/svpscmap.h, src/cff/cffcmap.c, + src/psaux/t1cmap.c, src/psnames/psmodule.c: Fix for the memory + leak described in bug #16759. + + We change 'ps_unicodes_init' so that it also takes a 'free_glyph_name' + callback to release the glyph names returned by 'get_glyph_name' + + 2006-06-04 David Turner <[EMAIL PROTECTED]> * src/base/ftutil.c (ft_mem_qrealloc): Fix the function to accept Index: include/freetype/internal/services/svpscmap.h =================================================================== RCS file: /cvsroot/freetype/freetype2/include/freetype/internal/services/svpscmap.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -b -r1.4 -r1.5 --- include/freetype/internal/services/svpscmap.h 12 Jan 2006 08:12:26 -0000 1.4 +++ include/freetype/internal/services/svpscmap.h 6 Jun 2006 08:14:14 -0000 1.5 @@ -75,14 +75,23 @@ * NULL if invalid index. */ typedef const char* - (*PS_Glyph_NameFunc)( FT_Pointer data, + (*PS_GetGlyphNameFunc)( FT_Pointer data, FT_UInt string_index ); + /* + * A function used to release the glyph name returned by + * PS_GetGlyphNameFunc, when needed + */ + typedef void + (*PS_FreeGlyphNameFunc)( FT_Pointer data, + const char* name ); + typedef FT_Error (*PS_Unicodes_InitFunc)( FT_Memory memory, PS_Unicodes unicodes, FT_UInt num_glyphs, - PS_Glyph_NameFunc get_glyph_name, + PS_GetGlyphNameFunc get_glyph_name, + PS_FreeGlyphNameFunc free_glyph_name, FT_Pointer glyph_data ); typedef FT_UInt Index: src/cff/cffcmap.c =================================================================== RCS file: /cvsroot/freetype/freetype2/src/cff/cffcmap.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -b -r1.15 -r1.16 --- src/cff/cffcmap.c 25 Feb 2006 14:53:02 -0000 1.15 +++ src/cff/cffcmap.c 6 Jun 2006 08:14:14 -0000 1.16 @@ -120,9 +120,10 @@ /*************************************************************************/ FT_CALLBACK_DEF( const char* ) - cff_sid_to_glyph_name( CFF_Font cff, + cff_sid_to_glyph_name( TT_Face face, FT_UInt idx ) { + CFF_Font cff = (CFF_Font) face->extra.data; CFF_Charset charset = &cff->charset; FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames; FT_UInt sid = charset->sids[idx]; @@ -131,6 +132,15 @@ return cff_index_get_sid_string( &cff->string_index, sid, psnames ); } + FT_CALLBACK_DEF( void ) + cff_sid_free_glyph_name( TT_Face face, + const char* gname ) + { + FT_Memory memory = FT_FACE_MEMORY( face ); + + FT_FREE( gname ); + } + FT_CALLBACK_DEF( FT_Error ) cff_cmap_unicode_init( PS_Unicodes unicodes ) @@ -149,7 +159,8 @@ return psnames->unicodes_init( memory, unicodes, cff->num_glyphs, - (PS_Glyph_NameFunc)&cff_sid_to_glyph_name, + (PS_GetGlyphNameFunc) &cff_sid_to_glyph_name, + (PS_FreeGlyphNameFunc) &cff_sid_free_glyph_name, (FT_Pointer)cff ); } Index: src/psaux/t1cmap.c =================================================================== RCS file: /cvsroot/freetype/freetype2/src/psaux/t1cmap.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -b -r1.17 -r1.18 --- src/psaux/t1cmap.c 25 Feb 2006 14:53:02 -0000 1.17 +++ src/psaux/t1cmap.c 6 Jun 2006 08:14:14 -0000 1.18 @@ -276,7 +276,8 @@ return psnames->unicodes_init( memory, unicodes, face->type1.num_glyphs, - (PS_Glyph_NameFunc)&t1_get_glyph_name, + (PS_GetGlyphNameFunc) &t1_get_glyph_name, + (PS_FreeGlyphNameFunc) NULL, (FT_Pointer)face ); } Index: src/psnames/psmodule.c =================================================================== RCS file: /cvsroot/freetype/freetype2/src/psnames/psmodule.c,v retrieving revision 1.43 retrieving revision 1.44 diff -u -b -r1.43 -r1.44 --- src/psnames/psmodule.c 17 Jan 2006 16:55:32 -0000 1.43 +++ src/psnames/psmodule.c 6 Jun 2006 08:14:14 -0000 1.44 @@ -185,7 +185,8 @@ ps_unicodes_init( FT_Memory memory, PS_Unicodes table, FT_UInt num_glyphs, - PS_Glyph_NameFunc get_glyph_name, + PS_GetGlyphNameFunc get_glyph_name, + PS_FreeGlyphNameFunc free_glyph_name, FT_Pointer glyph_data ) { FT_Error error; @@ -220,6 +221,9 @@ map->glyph_index = n; map++; } + + if ( free_glyph_name ) + free_glyph_name( glyph_data, gname ); } } _______________________________________________ Freetype-cvs mailing list Freetype-cvs@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype-cvs