fixed a potential memory leak when loading embedded bitmaps
This commit is contained in:
parent
c06eb3b73a
commit
c60c61c684
3
CHANGES
3
CHANGES
|
@ -53,6 +53,9 @@ LATEST CHANGES -
|
||||||
- updated the tutorial (not finished though).
|
- updated the tutorial (not finished though).
|
||||||
- updated the top-level BUILD document
|
- updated the top-level BUILD document
|
||||||
|
|
||||||
|
- fixed a potential memory leak that could occur when loading embedded
|
||||||
|
bitmaps.
|
||||||
|
|
||||||
- added the declaration of FT_New_Memory_Face in <freetype/freetype.h>, as
|
- added the declaration of FT_New_Memory_Face in <freetype/freetype.h>, as
|
||||||
it was missing from the public header (the implementation was already
|
it was missing from the public header (the implementation was already
|
||||||
in "ftobjs.c").
|
in "ftobjs.c").
|
||||||
|
|
|
@ -1304,10 +1304,17 @@
|
||||||
/* returned by FT_Load_Glyph(). */
|
/* returned by FT_Load_Glyph(). */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ft_glyph_own_bitmap = 1
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct FT_GlyphSlotRec_
|
typedef struct FT_GlyphSlotRec_
|
||||||
{
|
{
|
||||||
FT_Face face;
|
FT_Face face;
|
||||||
FT_GlyphSlot next;
|
FT_GlyphSlot next;
|
||||||
|
FT_UInt flags;
|
||||||
|
|
||||||
FT_Glyph_Metrics metrics;
|
FT_Glyph_Metrics metrics;
|
||||||
FT_Glyph_Metrics metrics2;
|
FT_Glyph_Metrics metrics2;
|
||||||
|
|
|
@ -1403,7 +1403,9 @@
|
||||||
ebdt_pos = FILE_Pos();
|
ebdt_pos = FILE_Pos();
|
||||||
|
|
||||||
/* clear the bitmap & load the bitmap */
|
/* clear the bitmap & load the bitmap */
|
||||||
|
if (face->root.glyph->flags & ft_glyph_own_bitmap)
|
||||||
FREE( map->buffer );
|
FREE( map->buffer );
|
||||||
|
|
||||||
map->rows = map->pitch = map->width = 0;
|
map->rows = map->pitch = map->width = 0;
|
||||||
|
|
||||||
error = Load_SBit_Image( strike, range, ebdt_pos, glyph_offset,
|
error = Load_SBit_Image( strike, range, ebdt_pos, glyph_offset,
|
||||||
|
@ -1411,6 +1413,9 @@
|
||||||
if ( error )
|
if ( error )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
|
/* the glyph slot owns this bitmap buffer */
|
||||||
|
face->root.glyph->flags |= ft_glyph_own_bitmap;
|
||||||
|
|
||||||
/* setup vertical metrics if needed */
|
/* setup vertical metrics if needed */
|
||||||
if ( strike->flags & 1 )
|
if ( strike->flags & 1 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -806,7 +806,10 @@
|
||||||
void TT_Done_GlyphSlot( TT_GlyphSlot slot )
|
void TT_Done_GlyphSlot( TT_GlyphSlot slot )
|
||||||
{
|
{
|
||||||
FT_Library library = slot->face->driver->library;
|
FT_Library library = slot->face->driver->library;
|
||||||
|
FT_Memory memory = library->memory;
|
||||||
|
|
||||||
|
if (slot->flags & ft_glyph_own_bitmap)
|
||||||
|
FREE( slot->bitmap.buffer );
|
||||||
|
|
||||||
FT_Outline_Done( library, &slot->outline );
|
FT_Outline_Done( library, &slot->outline );
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue