[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Devel] Memory leak in FT_Glyph_To_Bitmap
From: |
Graham Asher |
Subject: |
[Devel] Memory leak in FT_Glyph_To_Bitmap |
Date: |
Fri, 23 Feb 2001 14:22:15 -0000 |
(Please forgive me if this has already been found and fixed).
If the call to FT_Render_Glyph_Internal in FT_Glyph_To_Bitmap fails (in my
case because of a request for an unsupported render mode), the memory
allocated for the variable "bitmap" is not freed, resulting in a leak of 52
bytes.
The fix is as follows (new code enclosed in // GA .. // end GA):
FT_EXPORT_DEF( FT_Error ) FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
FT_ULong render_mode,
FT_Vector* origin,
FT_Bool destroy )
{
<snip>
/* create result bitmap glyph */
error = ft_new_glyph( glyph->library, &ft_bitmap_glyph_class,
(FT_Glyph*)&bitmap );
if ( error )
goto Exit;
/* prepare dummy slot for rendering */
error = clazz->glyph_prepare( glyph, &dummy );
if ( !error )
error = FT_Render_Glyph_Internal( glyph->library, &dummy, render_mode
);
// GA
if (error)
{
FT_Done_Glyph( FT_GLYPH( bitmap ) );
goto Exit;
}
// end GA
if ( !destroy && origin )
{
FT_Vector v;
v.x = -origin->x;
v.y = -origin->y;
FT_Glyph_Transform( glyph, 0, &v );
}
Graham Asher
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Devel] Memory leak in FT_Glyph_To_Bitmap,
Graham Asher <=